6
【笔记】JS实现URL编解码
source link: https://loli.fj.cn/2023/02/27/JS%E5%AE%9E%E7%8E%B0URL%E7%BC%96%E8%A7%A3%E7%A0%81/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
JS实现URL编解码
escape/unescape
- 对除ASCII字母、数字、特殊符号(
@
、*
、_
、+
、-
、.
、/
)以外的其他字符进行编码
URL编码
<str>
:未编码的字符串
escape("<str>");
URL解码
<str>
:已编码的字符串
unescape("<str>");
encodeURI/decodeURI
- 返回编码为有效的统一资源标识符(URI)的字符串
- 不会被编码的字符:
@
、*
、+
、/
、!
、#
、$
、&
、(
、)
、=
、:
、;
、?
、'
URL编码
<str>
:未编码的字符串
encodeURI("<str>");
URL解码
<str>
:已编码的字符串
decodeURI("<str>");
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK