From deab64a025a4424ff1359690c651f4a574b959ac Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 5 Aug 2014 15:24:33 -0400 Subject: [PATCH 1/2] revert fix($location): fix and test html5Mode url-parsing algorithm for legacy browsers This reverts commit 49e7c32bb45ce3984df6768ba7b2f6a723a4ebe7. --- src/ng/location.js | 21 +++++++++---------- test/ng/locationSpec.js | 45 ----------------------------------------- 2 files changed, 10 insertions(+), 56 deletions(-) diff --git a/src/ng/location.js b/src/ng/location.js index a73063bd5473..2ec139f8008f 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -663,34 +663,33 @@ function $LocationProvider(){ if (IGNORE_URI_REGEXP.test(absHref)) return; // 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 + // 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 - var href = elm.attr('href') || elm.attr('xlink:href'); + // 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('://') < 0) { // Ignore absolute URLs - var prefix = '#' + hashPrefix; + if (href.indexOf('://' == -1)) { // Ignore absolute URLs if (href[0] == '/') { // absolute path - replace old path - absHref = appBase + prefix + href; + absHref = serverBase(absHref) + href; } else if (href[0] == '#') { // local anchor - absHref = appBase + prefix + ($location.path() || '/') + href; + absHref = serverBase(absHref) + $location.path() + href; } else { // relative path - join with current path var stack = $location.path().split("/"), parts = href.split("/"); + stack.pop(); // remove top file for (var i=0; i= 9) { From 51e46dff1e33934df8d5bf55e4737ee9a11970d3 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 5 Aug 2014 15:26:16 -0400 Subject: [PATCH 2/2] revert fix($location): make legacy browsers behave like modern ones in html5Mode This reverts commit 3f047704c70a957596371fec554d3e1fb066a29d. Conflicts: src/ng/location.js --- src/ng/location.js | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/src/ng/location.js b/src/ng/location.js index 2ec139f8008f..48849672e82f 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -265,16 +265,6 @@ 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; - }; - } @@ -662,38 +652,6 @@ function $LocationProvider(){ // Ignore when url is started with javascript: or mailto: if (IGNORE_URI_REGEXP.test(absHref)) return; - // 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] == '/') { - // 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("/"), - parts = href.split("/"); - stack.pop(); // remove top file - for (var i=0; i