有人知道可以在GET中使用而不经过编码的完整字符列表吗?目前我使用A-Z - A-Z和0-9…但我想知道完整的名单。
我也感兴趣的是,是否会发布关于即将添加中文、阿拉伯语url的规范(显然这将对我的问题产生很大影响)。
有人知道可以在GET中使用而不经过编码的完整字符列表吗?目前我使用A-Z - A-Z和0-9…但我想知道完整的名单。
我也感兴趣的是,是否会发布关于即将添加中文、阿拉伯语url的规范(显然这将对我的问题产生很大影响)。
当前回答
RFC3986定义了两组你可以在URI中使用的字符:
Reserved Characters: :/?#[]@!$&'()*+,;= reserved = gen-delims / sub-delims gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" The purpose of reserved characters is to provide a set of delimiting characters that are distinguishable from other data within a URI. URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent. Unreserved Characters: A-Za-z0-9-_.~ unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" Characters that are allowed in a URI but do not have a reserved purpose are called unreserved.
其他回答
66个无保留字符的完整列表在RFC3986中,请访问:https://www.rfc-editor.org/rfc/rfc3986#section-2.3
这是以下正则表达式集中的任何字符:
[A-Za-z0-9_.\-~]
这些都列在RFC3986中。请参阅收集的ABNF中的URI,以了解在哪里允许什么,以及用于解析/验证的正则表达式。
如果你想给用户一种特殊的体验,你可以使用pushState将各种字符带到浏览器的url:
var u="";var tt=168;
for(var i=0; i< 250;i++){
var x = i+250*tt;
console.log(x);
var c = String.fromCharCode(x);
u+=c;
}
history.pushState({},"",250*tt+u);
编辑:正如@Jukka K. Korpela正确指出的那样,RFC 1738由RFC 3986更新。 这已经扩展和澄清了对主机有效的字符,不幸的是,它不容易复制和粘贴,但我会尽我所能。
按首先匹配的顺序排列:
host = IP-literal / IPv4address / reg-name
IP-literal = "[" ( IPv6address / IPvFuture ) "]"
IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
IPv6address = 6( h16 ":" ) ls32
/ "::" 5( h16 ":" ) ls32
/ [ h16 ] "::" 4( h16 ":" ) ls32
/ [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
/ [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
/ [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
/ [ *4( h16 ":" ) h16 ] "::" ls32
/ [ *5( h16 ":" ) h16 ] "::" h16
/ [ *6( h16 ":" ) h16 ] "::"
ls32 = ( h16 ":" h16 ) / IPv4address
; least-significant 32 bits of address
h16 = 1*4HEXDIG
; 16 bits of address represented in hexadecimal
IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
dec-octet = DIGIT ; 0-9
/ %x31-39 DIGIT ; 10-99
/ "1" 2DIGIT ; 100-199
/ "2" %x30-34 DIGIT ; 200-249
/ "25" %x30-35 ; 250-255
reg-name = *( unreserved / pct-encoded / sub-delims )
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" <---This seems like a practical shortcut, most closely resembling original answer
reserved = gen-delims / sub-delims
gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
pct-encoded = "%" HEXDIG HEXDIG
来自RFC 1738规范的原始答案:
因此,只有字母数字,特殊字符“$-_.+!*'(),”,和 可以使用用于保留目的的保留字符 没有在URL中编码。
^自1998年起过时。
RFC3986定义了两组你可以在URI中使用的字符:
Reserved Characters: :/?#[]@!$&'()*+,;= reserved = gen-delims / sub-delims gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" The purpose of reserved characters is to provide a set of delimiting characters that are distinguishable from other data within a URI. URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent. Unreserved Characters: A-Za-z0-9-_.~ unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" Characters that are allowed in a URI but do not have a reserved purpose are called unreserved.