@@ -38,6 +38,14 @@ function decodePath(path, html5Mode) {
38
38
return segments . join ( '/' ) ;
39
39
}
40
40
41
+ function normalizePath ( pathValue , searchValue , hashValue ) {
42
+ var search = toKeyValue ( searchValue ) ,
43
+ hash = hashValue ? '#' + encodeUriSegment ( hashValue ) : '' ,
44
+ path = encodePath ( pathValue ) ;
45
+
46
+ return path + ( search ? '?' + search : '' ) + hash ;
47
+ }
48
+
41
49
function parseAbsoluteUrl ( absoluteUrl , locationObj ) {
42
50
var parsedUrl = urlResolve ( absoluteUrl ) ;
43
51
@@ -143,18 +151,8 @@ function LocationHtml5Url(appBase, appBaseNoFile, basePrefix) {
143
151
this . $$compose ( ) ;
144
152
} ;
145
153
146
- /**
147
- * Compose url and update `absUrl` property
148
- * @private
149
- */
150
- this . $$compose = function ( ) {
151
- var search = toKeyValue ( this . $$search ) ,
152
- hash = this . $$hash ? '#' + encodeUriSegment ( this . $$hash ) : '' ;
153
-
154
- this . $$url = encodePath ( this . $$path ) + ( search ? '?' + search : '' ) + hash ;
155
- this . $$absUrl = appBaseNoFile + this . $$url . substr ( 1 ) ; // first char is always '/'
156
-
157
- this . $$urlUpdatedByLocation = true ;
154
+ this . $$normalizeUrl = function ( url ) {
155
+ return appBaseNoFile + url . substr ( 1 ) ; // first char is always '/'
158
156
} ;
159
157
160
158
this . $$parseLinkUrl = function ( url , relHref ) {
@@ -278,18 +276,8 @@ function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {
278
276
}
279
277
} ;
280
278
281
- /**
282
- * Compose hashbang URL and update `absUrl` property
283
- * @private
284
- */
285
- this . $$compose = function ( ) {
286
- var search = toKeyValue ( this . $$search ) ,
287
- hash = this . $$hash ? '#' + encodeUriSegment ( this . $$hash ) : '' ;
288
-
289
- this . $$url = encodePath ( this . $$path ) + ( search ? '?' + search : '' ) + hash ;
290
- this . $$absUrl = appBase + ( this . $$url ? hashPrefix + this . $$url : '' ) ;
291
-
292
- this . $$urlUpdatedByLocation = true ;
279
+ this . $$normalizeUrl = function ( url ) {
280
+ return appBase + ( url ? hashPrefix + url : '' ) ;
293
281
} ;
294
282
295
283
this . $$parseLinkUrl = function ( url , relHref ) {
@@ -340,17 +328,10 @@ function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) {
340
328
return ! ! rewrittenUrl ;
341
329
} ;
342
330
343
- this . $$compose = function ( ) {
344
- var search = toKeyValue ( this . $$search ) ,
345
- hash = this . $$hash ? '#' + encodeUriSegment ( this . $$hash ) : '' ;
346
-
347
- this . $$url = encodePath ( this . $$path ) + ( search ? '?' + search : '' ) + hash ;
331
+ this . $$normalizeUrl = function ( url ) {
348
332
// include hashPrefix in $$absUrl when $$url is empty so IE9 does not reload page because of removal of '#'
349
- this . $$absUrl = appBase + hashPrefix + this . $$url ;
350
-
351
- this . $$urlUpdatedByLocation = true ;
333
+ return appBase + hashPrefix + url ;
352
334
} ;
353
-
354
335
}
355
336
356
337
@@ -374,6 +355,16 @@ var locationPrototype = {
374
355
*/
375
356
$$replace : false ,
376
357
358
+ /**
359
+ * Compose url and update `url` and `absUrl` property
360
+ * @private
361
+ */
362
+ $$compose : function ( ) {
363
+ this . $$url = normalizePath ( this . $$path , this . $$search , this . $$hash ) ;
364
+ this . $$absUrl = this . $$normalizeUrl ( this . $$url ) ;
365
+ this . $$urlUpdatedByLocation = true ;
366
+ } ,
367
+
377
368
/**
378
369
* @ngdoc method
379
370
* @name $location#absUrl
0 commit comments