-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Potential fix for #6162 #6421
Potential fix for #6162 #6421
Changes from all commits
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 |
---|---|---|
|
@@ -268,6 +268,16 @@ function LocationHashbangInHtml5Url(appBase, hashPrefix) { | |
return appBaseNoFile; | ||
} | ||
}; | ||
|
||
this.$$compose = function() { | ||
var search = toKeyValue(this.$$search), | ||
hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; | ||
|
||
this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; | ||
// include hashPrefix in $$absUrl when $$url is empty so IE8 & 9 do not reload page because of removal of '#' | ||
this.$$absUrl = appBase + hashPrefix + this.$$url; | ||
}; | ||
|
||
} | ||
|
||
|
||
|
@@ -621,6 +631,38 @@ function $LocationProvider(){ | |
absHref = urlResolve(absHref.animVal).href; | ||
} | ||
|
||
// Make relative links work in HTML5 mode for legacy browsers (or at least IE8 & 9) | ||
// The href should be a regular url e.g. /link/somewhere or link/somewhere or ../somewhere or somewhere#anchor or http://example.com/somewhere | ||
if (LocationMode === LocationHashbangInHtml5Url) { | ||
// get the actual href attribute - see http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx | ||
// TODO check browser is in standards mode | ||
var href = elm[0].getAttribute('href'); | ||
|
||
if (href.indexOf('://' == -1)) { // Ignore absolute URLs | ||
if (href[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. Even though old IE is not supported, it's probably better to use |
||
// absolute path - replace old path | ||
absHref = serverBase(absHref) + href; | ||
} else if (href[0] == '#') { | ||
// local anchor | ||
absHref = serverBase(absHref) + $location.path() + href | ||
} else { | ||
// relative path - join with current path | ||
var stack = $location.path().split("/"), | ||
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. We really need test cases verifying this (actually, test cases verifying every unit of functionality added in this patch!), but especially this branch. Please add test cases for this, I'm happy to help if you need assistance. 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. @caitp. Please reread my comment On 28 March 2014 11:02, Caitlin Potter notifications@github.com wrote:
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 can help you fix failing tests and write new ones for your patch, but we do need tests. As for the timeframe this can be merged for, that's hard to say --- but having a mergeable patch will help make that soon. So, I can pair with you on getting this in, but it's going to take some extra work. 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. Sorry Caitlin, I just don't have the time to take this further. What I've supplied your team with is simply the patch I used to get things It's just my opinion, but I think whoever originally wrote location.js and If the goal is to get location.js into an easy to maintain state. I would Basically, I wouldn't recommend just tidying up and merging my fix. The disparity between actual and documented browser support, and Sorry I cannot be of any help. On 28 March 2014 12:02, Caitlin Potter notifications@github.com wrote:
|
||
parts = href.split("/"); | ||
stack.pop(); // remove top file | ||
for (var i=0; i<parts.length; i++) { | ||
if (parts[i] == ".") | ||
continue; | ||
else if (parts[i] == "..") | ||
stack.pop(); | ||
else | ||
stack.push(parts[i]); | ||
} | ||
absHref = serverBase(absHref) + stack.join("/"); | ||
} | ||
} | ||
} | ||
|
||
var rewrittenUrl = $location.$$rewrite(absHref); | ||
|
||
if (absHref && !elm.attr('target') && rewrittenUrl && !event.isDefaultPrevented()) { | ||
|
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.
href.indexOf('://') < 0
--- this currently meanshref.indexOf(false)