@@ -227,7 +227,7 @@ function pjax(options) {
227
227
228
228
var url = parseURL ( settings . url )
229
229
if ( hash ) url . hash = hash
230
- options . requestUrl = stripInternalParams ( url . href )
230
+ options . requestUrl = stripInternalParams ( url )
231
231
}
232
232
233
233
options . complete = function ( xhr , textStatus ) {
@@ -565,22 +565,12 @@ function cloneContents(container) {
565
565
return [ container . selector , cloned . contents ( ) ]
566
566
}
567
567
568
- // Internal: Strips named query param from url
568
+ // Internal: Strip internal query params from parsed URL.
569
569
//
570
- // url - String
571
- //
572
- // Returns String.
573
- function stripParam ( url , name ) {
574
- return url
575
- . replace ( new RegExp ( '[?&]' + name + '=[^&#]*' ) , '' )
576
- . replace ( / [ ? & ] ( $ | # ) / , '\1' )
577
- . replace ( / [ ? & ] / , '?' )
578
- }
579
-
570
+ // Returns sanitized url.href String.
580
571
function stripInternalParams ( url ) {
581
- url = stripParam ( url , '_pjax' )
582
- url = stripParam ( url , '_' )
583
- return url
572
+ url . search = url . search . replace ( / ( [ ? & ] ) ( _ p j a x | _ ) = [ ^ & ] * / g, '' )
573
+ return url . href . replace ( / \? ( $ | # ) / , '$1' )
584
574
}
585
575
586
576
// Internal: Parse URL components and returns a Locationish object.
@@ -697,7 +687,7 @@ function extractContainer(data, xhr, options) {
697
687
// Prefer X-PJAX-URL header if it was set, otherwise fallback to
698
688
// using the original requested url.
699
689
var serverUrl = xhr . getResponseHeader ( 'X-PJAX-URL' )
700
- obj . url = serverUrl ? stripInternalParams ( serverUrl ) : options . requestUrl
690
+ obj . url = serverUrl ? stripInternalParams ( parseURL ( serverUrl ) ) : options . requestUrl
701
691
702
692
// Attempt to parse response html into elements
703
693
if ( fullDocument ) {
0 commit comments