Closed Bug 441190 Opened 17 years ago Closed 4 years ago

location.search should return "?" for page http://www.example.com/index.html?

Categories

(Core :: DOM: Core & HTML, defect, P5)

defect

Tracking

()

RESOLVED INVALID

People

(Reporter: bugzilla, Unassigned)

References

()

Details

There is inconsistency between Gecko and other engines in location.search for URL like this: http://www.example.com/index.html? In Gecko (Firefox 3) location.search returns blank string but in IE, Opera and Safari it returns string "?". HTML5 spec defines prefix "?" for location.search getter and there is no exception for URLs http://www.example.com/index.html? http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#search I assume Firefox should follow other browsers behaviour. Testcase: http://tmp.met.cz/loc.html?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Indeed, the URL class we use to store the location doesn't differentiate between "no query string" and "blank query string" (i.e. URI ending with "?"), so the "location.search" getter code treats them both as "no query string" and returns "".
Note that the HTML5 spec is currently wrong about how to handle the case where there is not even a question mark (i.e. it says to handle http://example/? and http://example/ the same way).
HTML5 was fixed in r1826.
(This may also affect .port and .hash. Let me know if the spec is wrong and/or you don't want to implement exactly what it says for some reason. Thanks!)
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5

It should return the empty string per https://html.spec.whatwg.org/#dom-location-search and does so in all browsers today.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.