"key" 和 "key=" URL 查询字符串之间有区别吗?
Is there a difference between a "key" and "key=" URL query string?
例如,当我们解析这个查询字符串时:
foo&bar=&baz=123
Firefox 对标准 URLSearchParams
类型 (spec) 的实现将空字符串值分配给 foo
和 bar
:
这是否意味着 foo
和 foo=
在查询字符串中实际上是相同的?还是 Firefox 中的错误?
答案在 link 的规范中,您 post...
For each byte sequence bytes in sequences, run these substeps:
If bytes is the empty byte sequence, run these substeps for the next byte sequence.
If bytes contains a =
, then let name be the bytes from the start of bytes up to but excluding its first =
, and let value be the bytes, if any, after the first =
up to the end of bytes. If =
is the first byte, then name will be the empty byte sequence. If it is the last, then value will be the empty byte sequence.
Otherwise, let name have the value of bytes and let value be the empty byte sequence
所以...key 和 key= 相同...这不是错误。
例如,当我们解析这个查询字符串时:
foo&bar=&baz=123
Firefox 对标准 URLSearchParams
类型 (spec) 的实现将空字符串值分配给 foo
和 bar
:
这是否意味着 foo
和 foo=
在查询字符串中实际上是相同的?还是 Firefox 中的错误?
答案在 link 的规范中,您 post...
For each byte sequence bytes in sequences, run these substeps:
If bytes is the empty byte sequence, run these substeps for the next byte sequence.
If bytes contains a
=
, then let name be the bytes from the start of bytes up to but excluding its first=
, and let value be the bytes, if any, after the first=
up to the end of bytes. If=
is the first byte, then name will be the empty byte sequence. If it is the last, then value will be the empty byte sequence.Otherwise, let name have the value of bytes and let value be the empty byte sequence
所以...key 和 key= 相同...这不是错误。