Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($location): consider baseHref in relative link for legacy browsers #8233

Closed
wants to merge 6 commits into from
7 changes: 7 additions & 0 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,13 @@ function $LocationProvider(){
if (href.indexOf('://') < 0) { // Ignore absolute URLs
var prefix = '#' + hashPrefix;
if (href[0] == '/') {
// Account for base href already present in appBase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// use baseHref variable is fine

if (!baseHref && href.indexOf(baseHref) === 0) {
href = href.substr(baseHref.length);
if (!href || href[0] != '/') {
href = '/' + href;
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! I've updated accordingly

if ($browser.baseHref() != '' && href.indexOf($browser.baseHref()) === 0) {
href = href.substr($browser.baseHref().length);
if (href == '' || href[0] != '/') {
href = '/' + href;
}
}
// absolute path - replace old path
absHref = appBase + prefix + href;
} else if (href[0] == '#') {
Expand Down