Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($location): rewrite relative paths correctly path==='/' in legacy html5Mode #8684

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ function $LocationProvider(){
// relative path - join with current path
var stack = $location.path().split("/"),
parts = href.split("/");
if (stack.length === 2 && !stack[1]) stack.length = 1;
for (var i=0; i<parts.length; i++) {
if (parts[i] == ".")
continue;
Expand Down
14 changes: 14 additions & 0 deletions test/ng/locationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,20 @@ describe('$location', function() {
});


it('should produce relative paths correctly when $location.path() is "/" when history enabled on old browser', function() {
configureService('partial1', true, false, true);
inject(
initBrowser(),
initLocation(),
function($browser, $location) {
$location.path('/');
browserTrigger(link, 'click');
expectRewriteTo($browser, 'http://host.com/base/index.html#!/partial1');
}
);
});


it('should rewrite abs link to hashbang url when history enabled on old browser', function() {
configureService('/base/link?a#b', true, false);
inject(
Expand Down