@@ -39,7 +39,7 @@ function parseAppUrl(relativeUrl, locationObj, appBase) {
39
39
var match = urlResolve ( relativeUrl , appBase ) ;
40
40
locationObj . $$path = decodeURIComponent ( prefixed && match . pathname . charAt ( 0 ) === '/' ?
41
41
match . pathname . substring ( 1 ) : match . pathname ) ;
42
- locationObj . $$search = parseKeyValue ( match . search ) ;
42
+ locationObj . $$search = parseKeyValue ( match . search , locationObj . $$queryDelimiter ) ;
43
43
locationObj . $$hash = decodeURIComponent ( match . hash ) ;
44
44
45
45
// make sure path starts with '/';
@@ -87,9 +87,10 @@ function serverBase(url) {
87
87
* @param {string } appBase application base URL
88
88
* @param {string } basePrefix url path prefix
89
89
*/
90
- function LocationHtml5Url ( appBase , basePrefix ) {
90
+ function LocationHtml5Url ( appBase , basePrefix , queryDelimiter ) {
91
91
this . $$html5 = true ;
92
92
basePrefix = basePrefix || '' ;
93
+ this . $$queryDelimiter = queryDelimiter ;
93
94
var appBaseNoFile = stripFile ( appBase ) ;
94
95
parseAbsoluteUrl ( appBase , this , appBase ) ;
95
96
@@ -120,7 +121,7 @@ function LocationHtml5Url(appBase, basePrefix) {
120
121
* @private
121
122
*/
122
123
this . $$compose = function ( ) {
123
- var search = toKeyValue ( this . $$search ) ,
124
+ var search = toKeyValue ( this . $$search , this . $$queryDelimiter ) ,
124
125
hash = this . $$hash ? '#' + encodeUriSegment ( this . $$hash ) : '' ;
125
126
126
127
this . $$url = encodePath ( this . $$path ) + ( search ? '?' + search : '' ) + hash ;
@@ -155,8 +156,9 @@ function LocationHtml5Url(appBase, basePrefix) {
155
156
* @param {string } appBase application base URL
156
157
* @param {string } hashPrefix hashbang prefix
157
158
*/
158
- function LocationHashbangUrl ( appBase , hashPrefix ) {
159
+ function LocationHashbangUrl ( appBase , hashPrefix , queryDelimiter ) {
159
160
var appBaseNoFile = stripFile ( appBase ) ;
161
+ this . $$queryDelimiter = queryDelimiter ;
160
162
161
163
parseAbsoluteUrl ( appBase , this , appBase ) ;
162
164
@@ -227,7 +229,7 @@ function LocationHashbangUrl(appBase, hashPrefix) {
227
229
* @private
228
230
*/
229
231
this . $$compose = function ( ) {
230
- var search = toKeyValue ( this . $$search ) ,
232
+ var search = toKeyValue ( this . $$search , this . $$queryDelimiter ) ,
231
233
hash = this . $$hash ? '#' + encodeUriSegment ( this . $$hash ) : '' ;
232
234
233
235
this . $$url = encodePath ( this . $$path ) + ( search ? '?' + search : '' ) + hash ;
@@ -287,6 +289,12 @@ LocationHashbangInHtml5Url.prototype =
287
289
*/
288
290
$$replace : false ,
289
291
292
+ /**
293
+ * Allows using ";" instead of "&" to separate query string arguments
294
+ * @private
295
+ */
296
+ $$queryDelimiter : '&' ,
297
+
290
298
/**
291
299
* @ngdoc method
292
300
* @name $location#absUrl
@@ -415,7 +423,7 @@ LocationHashbangInHtml5Url.prototype =
415
423
return this . $$search ;
416
424
case 1 :
417
425
if ( isString ( search ) ) {
418
- this . $$search = parseKeyValue ( search ) ;
426
+ this . $$search = parseKeyValue ( search , this . $$queryDelimiter ) ;
419
427
} else if ( isObject ( search ) ) {
420
428
this . $$search = search ;
421
429
} else {
@@ -520,7 +528,8 @@ function locationGetterSetter(property, preprocess) {
520
528
*/
521
529
function $LocationProvider ( ) {
522
530
var hashPrefix = '' ,
523
- html5Mode = false ;
531
+ html5Mode = false ,
532
+ queryDelimiter = '&' ;
524
533
525
534
/**
526
535
* @ngdoc property
@@ -554,6 +563,26 @@ function $LocationProvider(){
554
563
}
555
564
} ;
556
565
566
+ /**
567
+ * @ngdoc property
568
+ * @name ng.$locationProvider#queryDelimiter
569
+ * @methodOf ng.$locationProvider
570
+ * @description
571
+ * @param {string= } delimiter String to use as a delimiter for query parameters. Must be '&' or
572
+ * ';'
573
+ * @returns {* } current value if used as getter or itself (chaining) if used as setter
574
+ */
575
+ this . queryDelimiter = function ( delimiter ) {
576
+ if ( arguments . length > 0 ) {
577
+ if ( delimiter !== ';' && delimiter !== '&' ) {
578
+ delimiter = '&' ;
579
+ }
580
+ queryDelimiter = delimiter ;
581
+ return this ;
582
+ }
583
+ return queryDelimiter ;
584
+ } ;
585
+
557
586
/**
558
587
* @ngdoc event
559
588
* @name $location#$locationChangeStart
@@ -596,7 +625,7 @@ function $LocationProvider(){
596
625
appBase = stripHash ( initialUrl ) ;
597
626
LocationMode = LocationHashbangUrl ;
598
627
}
599
- $location = new LocationMode ( appBase , '#' + hashPrefix ) ;
628
+ $location = new LocationMode ( appBase , '#' + hashPrefix , queryDelimiter ) ;
600
629
$location . $$parse ( $location . $$rewrite ( initialUrl ) ) ;
601
630
602
631
$rootElement . on ( 'click' , function ( event ) {
0 commit comments