@@ -227,7 +227,7 @@ function pjax(options) {
227227
228228 var url = parseURL ( settings . url )
229229 if ( hash ) url . hash = hash
230- options . requestUrl = stripInternalParams ( url . href )
230+ options . requestUrl = stripInternalParams ( url )
231231 }
232232
233233 options . complete = function ( xhr , textStatus ) {
@@ -565,22 +565,12 @@ function cloneContents(container) {
565565 return [ container . selector , cloned . contents ( ) ]
566566}
567567
568- // Internal: Strips named query param from url
568+ // Internal: Strip internal query params from parsed URL.
569569//
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.
580571function 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' )
584574}
585575
586576// Internal: Parse URL components and returns a Locationish object.
@@ -697,7 +687,7 @@ function extractContainer(data, xhr, options) {
697687 // Prefer X-PJAX-URL header if it was set, otherwise fallback to
698688 // using the original requested url.
699689 var serverUrl = xhr . getResponseHeader ( 'X-PJAX-URL' )
700- obj . url = serverUrl ? stripInternalParams ( serverUrl ) : options . requestUrl
690+ obj . url = serverUrl ? stripInternalParams ( parseURL ( serverUrl ) ) : options . requestUrl
701691
702692 // Attempt to parse response html into elements
703693 if ( fullDocument ) {
0 commit comments