Why doesn't Twitter and Google API documentation encode ampersands in URLs?

最后都变了- 提交于 2019-12-03 23:36:33

Is there any real benefit from not escaping ampersand in links?

It saves a few keystrokes.

Is this related to browser quirks?

No

Is this just a mistake in documentation?

Yes

Is there a reason API documentation by respectable companies often violates this rule?

Ignorance and/or laziness. Browsers perform error recovery so they either don't notice the errors or they don't care. The documentation probably isn't written by their best experts.

Two different contexts here.

  1. Within the context of a javascript href, the & is just fine and should not be encoded.
  2. In an HTML link the & is forbidden and should be escaped.

In the HTML link context an HTML character entity will be decoded before the address is passed to the HTTP process; a URL-encoded character will not, as the server can read it directly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!