-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($location): consider baseHref in relative link for legacy browsers #8233
Changes from all commits
25da859
df05668
dfd2959
b6d00f7
5b99a00
b65fd3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
if (baseHref && href.indexOf(baseHref) === 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is quite right. Assuming we have a base tag like
The issues are, 1) we're not really correctly resolving relative to the baseURI for absolute references, and 2) we're not resolving relative URIs correctly this way at all, because this branch is only ever evaluated for absolute uris (uris beginning with a We need to fix this up |
||
href = href.substr(baseHref.length); | ||
if (!href || href[0] != '/') { | ||
href = '/' + href; | ||
} | ||
} | ||
// absolute path - replace old path | ||
absHref = appBase + prefix + href; | ||
} else if (href[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.
// use baseHref variable is fine
if (!baseHref && href.indexOf(baseHref) === 0) {
href = href.substr(baseHref.length);
if (!href || href[0] != '/') {
href = '/' + href;
}
}
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.
thanks! I've updated accordingly