Allowed? & Allowed in URL

I was looking at the code, and I saw something like this:

if (result.indexOf('?') === -1) {
    result += '?';
}
result += '&' + SOMETHING;

Obviously, this can lead to a URL like this http://example.com?&a=b

The author of the code does not see anything unusual in the code, but ? & bothers me. I could not find any restrictions in the RFC for the URI to prove it was wrong (or maybe I skipped this).

Obviously, on the Chrome dev toolbar tab, it looks like an empty pair: enter image description here

Should such a URL bother me or am I just paranoid?

+4
source share
2 answers

, , . , , ? &, =.

, ? a & ( & ') , . = "" null, .

, , (, JavaScript).

+6

.

tl; dr: yes, ?&example

, , "" null.

, , , URL- ?&foo=bar, foo.

+4

Source: https://habr.com/ru/post/1669846/


All Articles