Issue metadata
Sign in to add a comment
|
location.href = "string" appends the
Reported by
ben.gr...@20minuten.ch,
Sep 25
|
||||||||||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 Steps to reproduce the problem: 1. Load a website and navigate at least one level down its heirarchy, eg mysite.com/a/b/ 2. set the window.location.href to a string without a leading /, eg "foo" 3. What is the expected behavior? reload the page to mysite.com/foo What went wrong? the foo gets appended, and site attempts to load mysite.com/a/b/foo Setting the href to "/foo" results in the expected behaviour Did this work before? Yes Chrome 68 Does this work in other browsers? Yes Chrome version: 69.0.3497.100 Channel: stable OS Version: OS X 10.13.5 Flash Version:
,
Sep 25
I am pretty sure your expectation is incorrect... location.href = "foo" works just like clicking on <a href="foo">. If your current URL ends with a / and href is set to something that does not begin with / or ../, it will indeed be (and rightfully so) appended to the URL. If the current URL does not end with slash, it will replace whatever it is that follows the last /. If you want to go to a top level path, you must prepend / to the href. I am using Chrome 68 and the same behavior occurs. Internet Explorer 11 agrees with this behavior as well (for what it is worth ;)).
,
Sep 26
reporter@ - Could you please respond as per comment #2. Hence, adding Needs-Feedback label. Thanks...!!
,
Oct 29
Mac triage: #2 is correct - the report's expected behavior is incorrect. You want location.href = "/string". As such, this is not a bug. |
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by vamshi.kommuri@chromium.org
, Sep 25