File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -3503,17 +3503,26 @@ function hrefSanitizer(
35033503 }
35043504 return '' ;
35053505 } ;
3506+ const extractParam = ( href , source ) => {
3507+ if ( Boolean ( source ) === false ) { return href ; }
3508+ const recursive = source . includes ( '?' , 1 ) ;
3509+ const end = recursive ? source . indexOf ( '?' , 1 ) : source . length ;
3510+ try {
3511+ const url = new URL ( href , document . location ) ;
3512+ const value = url . searchParams . get ( source . slice ( 1 , end ) ) ;
3513+ if ( value === null ) { return href }
3514+ if ( recursive ) { return extractParam ( value , source . slice ( end ) ) ; }
3515+ return value ;
3516+ } catch ( x ) {
3517+ }
3518+ return href ;
3519+ } ;
35063520 const extractText = ( elem , source ) => {
35073521 if ( / ^ \[ .* \] $ / . test ( source ) ) {
35083522 return elem . getAttribute ( source . slice ( 1 , - 1 ) . trim ( ) ) || '' ;
35093523 }
35103524 if ( source . startsWith ( '?' ) ) {
3511- try {
3512- const url = new URL ( elem . href , document . location ) ;
3513- return url . searchParams . get ( source . slice ( 1 ) ) || '' ;
3514- } catch ( x ) {
3515- }
3516- return '' ;
3525+ return extractParam ( elem . href , source ) ;
35173526 }
35183527 if ( source === 'text' ) {
35193528 return elem . textContent
You can’t perform that action at this time.
0 commit comments