aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ng/location.js3
-rw-r--r--test/ng/locationSpec.js82
2 files changed, 85 insertions, 0 deletions
diff --git a/src/ng/location.js b/src/ng/location.js
index 6bed261f..9feee5ad 100644
--- a/src/ng/location.js
+++ b/src/ng/location.js
@@ -503,6 +503,9 @@ function $LocationProvider(){
var href = elm.attr('href');
if (!href || isDefined(elm.attr('ng-ext-link')) || elm.attr('target')) return;
+ // link to different base path
+ if (href[0] === '/' && href.indexOf(pathPrefix) !== 0) return;
+
// remove same domain from full url links (IE7 always returns full hrefs)
href = href.replace(absUrlPrefix, '');
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js
index 18f884fe..98167b4e 100644
--- a/test/ng/locationSpec.js
+++ b/test/ng/locationSpec.js
@@ -864,6 +864,88 @@ describe('$location', function() {
});
+ it('should not rewrite when link to different base path when history enabled on new browser',
+ function() {
+ configureService('/other_base/link', true, true);
+ inject(
+ initBrowser(),
+ initLocation(),
+ function($browser) {
+ browserTrigger(link, 'click');
+ expectNoRewrite($browser);
+ }
+ );
+ });
+
+
+ it('should not rewrite when link to different base path when history enabled on old browser',
+ function() {
+ configureService('/other_base/link', true, false);
+ inject(
+ initBrowser(),
+ initLocation(),
+ function($browser) {
+ browserTrigger(link, 'click');
+ expectNoRewrite($browser);
+ }
+ );
+ });
+
+
+ it('should not rewrite when link to different base path when history disabled', function() {
+ configureService('/other_base/link', false);
+ inject(
+ initBrowser(),
+ initLocation(),
+ function($browser) {
+ browserTrigger(link, 'click');
+ expectNoRewrite($browser);
+ }
+ );
+ });
+
+
+ it('should not rewrite when full link to different base path when history enabled on new browser',
+ function() {
+ configureService('http://host.com/other_base/link', true, true);
+ inject(
+ initBrowser(),
+ initLocation(),
+ function($browser) {
+ browserTrigger(link, 'click');
+ expectNoRewrite($browser);
+ }
+ );
+ });
+
+
+ it('should not rewrite when full link to different base path when history enabled on old browser',
+ function() {
+ configureService('http://host.com/other_base/link', true, false);
+ inject(
+ initBrowser(),
+ initLocation(),
+ function($browser) {
+ browserTrigger(link, 'click');
+ expectNoRewrite($browser);
+ }
+ );
+ });
+
+
+ it('should not rewrite when full link to different base path when history disabled', function() {
+ configureService('http://host.com/other_base/link', false);
+ inject(
+ initBrowser(),
+ initLocation(),
+ function($browser) {
+ browserTrigger(link, 'click');
+ expectNoRewrite($browser);
+ }
+ );
+ });
+
+
// don't run next tests on IE<9, as browserTrigger does not simulate pressed keys
if (!(msie < 9)) {