New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 889006 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Oct 29
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

location.href = "string" appends the

Reported by ben.gr...@20minuten.ch, Sep 25

Issue description

UserAgent: 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:
 
Labels: Needs-Bisect Needs-Triage-M69
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 ;)).
Cc: krajshree@chromium.org
Labels: Triaged-ET Needs-Feedback
reporter@ - Could you please respond as per comment #2. Hence, adding Needs-Feedback label.
Thanks...!!
Status: WontFix (was: Unconfirmed)
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