javascript - "key"和 "key="URL 查询字符串之间有区别吗?

标签 javascript url firefox query-string

例如,当我们解析这个查询字符串时:

foo&bar=&baz=123

Firefox 对标准 URLSearchParams 类型 ( spec ) 的实现为 foobar 分配一个空字符串值:

enter image description here

这是否意味着 foofoo= 在查询字符串中实际上是相同的?还是 Firefox 中的一个错误?

最佳答案

答案就在您发布的链接的规范中......

For each byte sequence bytes in sequences, run these substeps:

  1. If bytes is the empty byte sequence, run these substeps for the next byte sequence.

  2. 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.

  3. Otherwise, let name have the value of bytes and let value be the empty byte sequence

所以... key 和 key= 是相同的...这不是一个错误。

关于javascript - "key"和 "key="URL 查询字符串之间有区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30538760/

相关文章:

JavaScript 闭包和作用域链

JavaScript 隐藏/显示元素

javascript - 去除引号以外的所有空格

javascript - 如何在同一篇文章中从上面的元素中获取图像 url 和标题

javascript - iframe (javascript) + 正确的网址

firefox - 不明白为什么 Firefox 在我的文本后面显示白色背景

php - 在 $_POST 之后保持 JavaScript 效果

css3 moz-linear-gradient 不工作

css - firefox 将白色边框添加到渲染图像

javascript - 在 onclick url 中使用数据绑定(bind)