在 data url 中使用 base64 的 url safe 变体是合法的吗?

2021-10-29 16:45:57 +08:00
 Kaciras

比如:

data:image/gif;base64,ZBLARqvF4-_cDUmPkjsH

能否写成

data:image/gif;base64,ZBLARqvF4+/cDUmPkjsH
878 次点击
所在节点    问与答
2 条回复
ysc3839
2021-10-29 17:06:34 +08:00
你搞反了吧?

按照维基百科的说法: https://en.wikipedia.org/wiki/Data_URI_scheme
Note that Base64-encoded data: URIs use the standard Base64 character set (with '+' and '/' as characters 62 and 63) rather than the so-called "URL-safe Base64" character set.

RFC 2397 里没有明确指出,但是给了一段包含+和 /的 example 。
https://datatracker.ietf.org/doc/html/rfc2397
Kaciras
2021-10-29 17:11:26 +08:00
@ysc3839 谢谢,看来是不能用 URL-safe Base64

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/811567

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX