@@ -37,15 +37,17 @@ function parseAppUrl(relativeUrl, locationObj, appBase) {
37
37
relativeUrl = '/' + relativeUrl ;
38
38
}
39
39
var match = urlResolve ( relativeUrl , appBase ) ;
40
- locationObj . $$path = decodeURIComponent ( prefixed && match . pathname . charAt ( 0 ) === '/' ?
41
- match . pathname . substring ( 1 ) : match . pathname ) ;
42
- locationObj . $$search = parseKeyValue ( match . search ) ;
43
- locationObj . $$hash = decodeURIComponent ( match . hash ) ;
40
+ locationObj . pathEncoded = prefixed && match . pathname . charAt ( 0 ) === '/' ?
41
+ match . pathname . substring ( 1 ) : match . pathname ;
44
42
45
43
// make sure path starts with '/';
46
- if ( locationObj . $$path && locationObj . $$path . charAt ( 0 ) != '/' ) {
47
- locationObj . $$path = '/' + locationObj . $$path ;
44
+ if ( locationObj . pathEncoded && locationObj . pathEncoded . charAt ( 0 ) != '/' ) {
45
+ locationObj . pathEncoded = '/' + locationObj . pathEncoded ;
48
46
}
47
+
48
+ locationObj . $$path = decodeURIComponent ( locationObj . pathEncoded ) ;
49
+ locationObj . $$search = parseKeyValue ( match . search ) ;
50
+ locationObj . $$hash = decodeURIComponent ( match . hash ) ;
49
51
}
50
52
51
53
@@ -123,7 +125,7 @@ function LocationHtml5Url(appBase, basePrefix) {
123
125
var search = toKeyValue ( this . $$search ) ,
124
126
hash = this . $$hash ? '#' + encodeUriSegment ( this . $$hash ) : '' ;
125
127
126
- this . $$url = encodePath ( this . $$path ) + ( search ? '?' + search : '' ) + hash ;
128
+ this . $$url = this . pathEncoded + ( search ? '?' + search : '' ) + hash ;
127
129
this . $$absUrl = appBaseNoFile + this . $$url . substr ( 1 ) ; // first char is always '/'
128
130
} ;
129
131
@@ -190,7 +192,7 @@ function LocationHashbangUrl(appBase, hashPrefix) {
190
192
var search = toKeyValue ( this . $$search ) ,
191
193
hash = this . $$hash ? '#' + encodeUriSegment ( this . $$hash ) : '' ;
192
194
193
- this . $$url = encodePath ( this . $$path ) + ( search ? '?' + search : '' ) + hash ;
195
+ this . $$url = this . pathEncoded + ( search ? '?' + search : '' ) + hash ;
194
196
this . $$absUrl = appBase + ( this . $$url ? hashPrefix + this . $$url : '' ) ;
195
197
} ;
196
198
@@ -350,8 +352,10 @@ LocationHashbangInHtml5Url.prototype =
350
352
* @param {string= } path New path
351
353
* @return {string } path
352
354
*/
353
- path : locationGetterSetter ( '$$path' , function ( path ) {
354
- return path . charAt ( 0 ) == '/' ? path : '/' + path ;
355
+ path : locationGetterSetter ( '$$path' , function ( path , locationObj ) {
356
+ path = path . charAt ( 0 ) == '/' ? path : '/' + path ;
357
+ locationObj . pathEncoded = encodePath ( path ) ;
358
+ return path ;
355
359
} ) ,
356
360
357
361
/**
@@ -446,7 +450,7 @@ function locationGetterSetter(property, preprocess) {
446
450
if ( isUndefined ( value ) )
447
451
return this [ property ] ;
448
452
449
- this [ property ] = preprocess ( value ) ;
453
+ this [ property ] = preprocess ( value , this ) ;
450
454
this . $$compose ( ) ;
451
455
452
456
return this ;
0 commit comments