Skip to content

Commit f965429

Browse files
fix($location): don't break on numeric path arguments
Fixes angular#7054
1 parent 8d0cb30 commit f965429

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/ng/location.js

+1
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ LocationHashbangInHtml5Url.prototype =
395395
* @return {string} path
396396
*/
397397
path: locationGetterSetter('$$path', function(path) {
398+
path = isString(path) ? path : '' + path;
398399
return path.charAt(0) == '/' ? path : '/' + path;
399400
}),
400401

test/ng/locationSpec.js

+5
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ describe('$location', function() {
8686
expect(url.absUrl()).toBe('http://www.domain.com:9877/new/path?search=a&b=c&d#hash');
8787
});
8888

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

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

0 commit comments

Comments
 (0)