Thanks to visit codestin.com
Credit goes to github.com

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

fix($location): don't break on numeric path arguments #7161

Closed
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 @@ -395,6 +395,7 @@ LocationHashbangInHtml5Url.prototype =
* @return {string} path
*/
path: locationGetterSetter('$$path', function(path) {
path = isString(path) ? path : '' + path;
return path.charAt(0) == '/' ? path : '/' + path;
}),

Expand Down
5 changes: 5 additions & 0 deletions test/ng/locationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ describe('$location', function() {
expect(url.absUrl()).toBe('http://www.domain.com:9877/new/path?search=a&b=c&d#hash');
});

it('path() should not break on numeric values', function() {
url.path(1);
expect(url.path()).toBe('/1');
expect(url.absUrl()).toBe('http://www.domain.com:9877/1?search=a&b=c&d#hash');
});

it('search() should accept string', function() {
url.search('x=y&c');
Expand Down