diff options
| author | Misko Hevery | 2012-06-12 13:33:57 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-06-13 10:49:05 -0700 |
| commit | 0f44964e5e0f7e37d7fa3216bb10fd61fbf52ae2 (patch) | |
| tree | 55477f9c951816499fffa093f05ae09d0849f5fe /test/ng/locationSpec.js | |
| parent | f6b09b913968d578010ca757e9d0d9ceed67027a (diff) | |
| download | angular.js-0f44964e5e0f7e37d7fa3216bb10fd61fbf52ae2.tar.bz2 | |
fix($location): correctly parse link urls in hashbang mode with prefix
This is a second fix for a regression that was introduced by 92a2e180.
The fix addresses scenarios when the $location service is configured with
a hash prefix.
Closes #1037
Diffstat (limited to 'test/ng/locationSpec.js')
| -rw-r--r-- | test/ng/locationSpec.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index 543232c3..91f3688c 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -999,6 +999,36 @@ describe('$location', function() { $rootElement.remove(); }); }); + + + it('should not mess up hash urls when clicking on links in hashbang mode with a prefix', + function() { + var base; + module(function($locationProvider) { + return function($browser) { + window.location.hash = '!someHash'; + $browser.url(base = window.location.href); + base = base.split('#')[0]; + $locationProvider.hashPrefix('!'); + } + }); + inject(function($rootScope, $compile, $browser, $rootElement, $document, $location) { + // we need to do this otherwise we can't simulate events + $document.find('body').append($rootElement); + + var element = $compile('<a href="#!/view1">v1</a><a href="#!/view2">v2</a>')($rootScope); + $rootElement.append(element); + var av1 = $rootElement.find('a').eq(0); + var av2 = $rootElement.find('a').eq(1); + + + browserTrigger(av1, 'click'); + expect($browser.url()).toEqual(base + '#!/view1'); + + browserTrigger(av2, 'click'); + expect($browser.url()).toEqual(base + '#!/view2'); + }); + }); }); |
