@@ -561,34 +561,38 @@ var Gatekeeper = /** @class */ (function () {
561561 }
562562 // Decode once to get the actual URL
563563 var decodedURL = decodeURIComponent ( destinationUrl ) ;
564- // Parse URL to handle parameters properly
565- var urlParts = decodedURL . split ( '?' ) ;
566- var baseUrl = urlParts [ 0 ] ;
567- var queryString = urlParts [ 1 ] || '' ;
568- // Parse existing parameters while preserving their values
564+ // Build new CrowdHandler parameters
565+ var chParams = [
566+ "ch-id=" . concat ( encodeURIComponent ( this . token || '' ) ) ,
567+ "ch-id-signature=" . concat ( encodeURIComponent ( ( ( _d = ( _c = this . sessionStatus ) === null || _c === void 0 ? void 0 : _c . result ) === null || _d === void 0 ? void 0 : _d . hash ) || '' ) ) ,
568+ "ch-requested=" . concat ( encodeURIComponent ( ( ( _f = ( _e = this . sessionStatus ) === null || _e === void 0 ? void 0 : _e . result ) === null || _f === void 0 ? void 0 : _f . requested ) || this . requested || this . specialParameters . chRequested || '' ) ) ,
569+ "ch-code=" . concat ( encodeURIComponent ( this . specialParameters . chCode || '' ) ) ,
570+ "ch-fresh=true"
571+ ] ;
572+ // Separate hash fragment before parsing query params. This ensures
573+ // ch-* params are placed in the real query string (window.location.search)
574+ // rather than inside the hash fragment where host-domain scripts cannot
575+ // read them via URLSearchParams.
576+ var hashIndex = decodedURL . indexOf ( '#' ) ;
577+ var urlWithoutHash = hashIndex !== - 1 ? decodedURL . substring ( 0 , hashIndex ) : decodedURL ;
578+ var hashPart = hashIndex !== - 1 ? decodedURL . substring ( hashIndex ) : '' ;
579+ // Parse existing query string, stripping any existing ch-* params
580+ var _g = urlWithoutHash . split ( '?' ) , baseUrl = _g [ 0 ] , queryParts = _g . slice ( 1 ) ;
581+ var queryString = queryParts . join ( '?' ) ;
569582 var existingParams = [ ] ;
570583 if ( queryString ) {
571584 var params = queryString . split ( '&' ) ;
572585 for ( var _i = 0 , params_1 = params ; _i < params_1 . length ; _i ++ ) {
573586 var param = params_1 [ _i ] ;
574587 var key = param . split ( '=' ) [ 0 ] ;
575- // Skip CrowdHandler parameters
576588 if ( ! [ 'ch-id' , 'ch-id-signature' , 'ch-requested' , 'ch-code' , 'ch-fresh' ] . includes ( key ) ) {
577589 existingParams . push ( param ) ;
578590 }
579591 }
580592 }
581- // Build new CrowdHandler parameters
582- var chParams = [
583- "ch-id=" . concat ( encodeURIComponent ( this . token || '' ) ) ,
584- "ch-id-signature=" . concat ( encodeURIComponent ( ( ( _d = ( _c = this . sessionStatus ) === null || _c === void 0 ? void 0 : _c . result ) === null || _d === void 0 ? void 0 : _d . hash ) || '' ) ) ,
585- "ch-requested=" . concat ( encodeURIComponent ( ( ( _f = ( _e = this . sessionStatus ) === null || _e === void 0 ? void 0 : _e . result ) === null || _f === void 0 ? void 0 : _f . requested ) || this . requested || this . specialParameters . chRequested || '' ) ) ,
586- "ch-code=" . concat ( encodeURIComponent ( this . specialParameters . chCode || '' ) ) ,
587- "ch-fresh=true"
588- ] ;
589- // Construct final URL
593+ // Construct final URL with ch-* params before any hash fragment
590594 var allParams = existingParams . concat ( chParams ) ;
591- var finalUrl = baseUrl + ( allParams . length > 0 ? '?' + allParams . join ( '&' ) : '' ) ;
595+ var finalUrl = baseUrl + ( allParams . length > 0 ? '?' + allParams . join ( '&' ) : '' ) + hashPart ;
592596 ( 0 , logger_1 . logger ) ( this . options . debug , "info" , "[WaitingRoom] Redirecting promoted user to: " . concat ( finalUrl ) ) ;
593597 return this . REQUEST . redirect ( finalUrl ) ;
594598 }
0 commit comments