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 @@ -416,7 +416,7 @@ LocationHashbangInHtml5Url.prototype =
416
416
* @return {string } path
417
417
*/
418
418
path : locationGetterSetter ( '$$path' , function ( path ) {
419
- path = path ? path . toString ( ) : '' ;
419
+ path = path !== null ? path . toString ( ) : '' ;
420
420
return path . charAt ( 0 ) == '/' ? path : '/' + path ;
421
421
} ) ,
422
422
@@ -513,7 +513,7 @@ LocationHashbangInHtml5Url.prototype =
513
513
* @return {string } hash
514
514
*/
515
515
hash : locationGetterSetter ( '$$hash' , function ( hash ) {
516
- return hash ? hash . toString ( ) : '' ;
516
+ return hash !== null ? hash . toString ( ) : '' ;
517
517
} ) ,
518
518
519
519
/**
Original file line number Diff line number Diff line change @@ -142,6 +142,11 @@ describe('$location', function() {
142
142
expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/1?search=a&b=c&d#hash' ) ;
143
143
} ) ;
144
144
145
+ it ( 'path() should allow using 0 as path' , function ( ) {
146
+ url . path ( 0 ) ;
147
+ expect ( url . path ( ) ) . toBe ( '/0' ) ;
148
+ expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/0?search=a&b=c&d#hash' ) ;
149
+ } ) ;
145
150
146
151
it ( 'path() should set to empty path on null value' , function ( ) {
147
152
url . path ( '/foo' ) ;
@@ -240,6 +245,11 @@ describe('$location', function() {
240
245
expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/path/b?search=a&b=c&d#5' ) ;
241
246
} ) ;
242
247
248
+ it ( 'hash() should allow using 0' , function ( ) {
249
+ url . hash ( 0 ) ;
250
+ expect ( url . hash ( ) ) . toBe ( '0' ) ;
251
+ expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/path/b?search=a&b=c&d#0' ) ;
252
+ } ) ;
243
253
244
254
it ( 'hash() should accept null parameter' , function ( ) {
245
255
url . hash ( null ) ;
You can’t perform that action at this time.
0 commit comments