This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -391,7 +391,7 @@ LocationHashbangInHtml5Url.prototype =
391
391
* @return {string } path
392
392
*/
393
393
path : locationGetterSetter ( '$$path' , function ( path ) {
394
- path = path ? path . toString ( ) : '' ;
394
+ path = path !== null ? path . toString ( ) : '' ;
395
395
return path . charAt ( 0 ) == '/' ? path : '/' + path ;
396
396
} ) ,
397
397
@@ -488,7 +488,7 @@ LocationHashbangInHtml5Url.prototype =
488
488
* @return {string } hash
489
489
*/
490
490
hash : locationGetterSetter ( '$$hash' , function ( hash ) {
491
- return hash ? hash . toString ( ) : '' ;
491
+ return hash !== null ? hash . toString ( ) : '' ;
492
492
} ) ,
493
493
494
494
/**
Original file line number Diff line number Diff line change @@ -93,6 +93,11 @@ describe('$location', function() {
93
93
expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/1?search=a&b=c&d#hash' ) ;
94
94
} ) ;
95
95
96
+ it ( 'path() should allow using 0 as path' , function ( ) {
97
+ url . path ( 0 ) ;
98
+ expect ( url . path ( ) ) . toBe ( '/0' ) ;
99
+ expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/0?search=a&b=c&d#hash' ) ;
100
+ } ) ;
96
101
97
102
it ( 'path() should set to empty path on null value' , function ( ) {
98
103
url . path ( '/foo' ) ;
@@ -191,6 +196,11 @@ describe('$location', function() {
191
196
expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/path/b?search=a&b=c&d#5' ) ;
192
197
} ) ;
193
198
199
+ it ( 'hash() should allow using 0' , function ( ) {
200
+ url . hash ( 0 ) ;
201
+ expect ( url . hash ( ) ) . toBe ( '0' ) ;
202
+ expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/path/b?search=a&b=c&d#0' ) ;
203
+ } ) ;
194
204
195
205
it ( 'hash() should accept null parameter' , function ( ) {
196
206
url . hash ( null ) ;
You can’t perform that action at this time.
0 commit comments