-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($location): always resolve relative links in html5mode to <base>
url
#8851
Conversation
@@ -127,21 +127,32 @@ function LocationHtml5Url(appBase, basePrefix) { | |||
this.$$absUrl = appBaseNoFile + this.$$url.substr(1); // first char is always '/' | |||
}; | |||
|
|||
this.$$rewrite = function(url) { | |||
this.$$parseLinkUrl = function(url, relHref) { | |||
if (relHref && relHref[0] === '#') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<a href="#!/path/foo">foo</a>
would be broken by this (more specifically, the LocationHashbangInHtml5Url case would break this --- but it's the same code in both)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is a breaking change. But in html5 mode you should not use those kinds of urls, right? They are used in plain hashbang mode (without html5Mode turned on)
It looks like this fails to deal with the |
Makes tests more readable
…` url BREAKING CHANGE (since 1.2.0 and 1.3.0-beta.1): Angular now requires a `<base>` tag when html5 mode of `$location` is enabled. Reasoning: Using html5 mode without a `<base href="...">` tag makes relative links for images, links, ... relative to the current url if the browser supports the history API. However, if the browser does not support the history API Angular falls back to using the `#`, and then all those relative links would be broken. The `<base>` tag is also needed when a deep url is loaded from the server, e.g. `http://server/some/page/url`. In that case, Angular needs to decide which part of the url is the base of the application, and which part is path inside of the application. To summarize: Now all relative links are always relative to the `<base>` tag. Exception (also a breaking change): Link tags whose `href` attribute starts with a `#` will only change the hash of the url, but nothing else (e.g. `<a href="#someAnchor">`). This is to make it easy to scroll to anchors inside a document. Related to angular#6162 Closes angular#8492 BREAKING CHANGE (since 1.2.17 and 1.3.0-beta.10): In html5 mode without a `<base>` tag on older browser that don't support the history API relative paths were adding up. E.g. clicking on `<a href="page1">` and then on `<a href="page2">` would produce `$location.path()==='/page1/page2'. The code that introduced this behavior was removed and Angular now also requires a `<base>` tag to be present when using html5 mode. Closes angular#8172, angular#8233
@caitp this is correct, but this also does not need to deal with those cases as:
I.e. a link of |
Landed as 2294880 |
BREAKING CHANGE (since 1.2.0 and 1.3.0-beta.1):
Angular now requires a
<base>
tag when html5 mode of$location
is enabled. Reasoning:Using html5 mode without a
<base href="...">
tag makes relative links for images, links, ...relative to the current url if the browser supports
the history API. However, if the browser does not support the history API Angular falls back to using the
#
,and then all links would be broken.
BREAKING CHANGE (since 1.2.17 and 1.3.0-beta.10):
In html5 mode without a
<base>
tag on older browser that don't support the history APIrelative paths were adding up. E.g. clicking on
<a href="page1">
and then on<a href="page2">
would produce
$location.path()==='/page1/page2'. The code that introduced this behavior was removed and Angular now also requires a
` tag to be present when using html5 mode.Closes #8172