@@ -327,12 +327,14 @@ function onBeforeRequest(details) {
327327 // If there is a username / password, put them aside during the ruleset
328328 // analysis process
329329 var using_credentials_in_url = false ;
330+ let tmp_user ;
331+ let tmp_pass ;
330332 if ( uri . password || uri . username ) {
331333 using_credentials_in_url = true ;
332- var tmp_user = uri . username ;
333- var tmp_pass = uri . password ;
334- uri . username = null ;
335- uri . password = null ;
334+ tmp_user = uri . username ;
335+ tmp_pass = uri . password ;
336+ uri . username = '' ;
337+ uri . password = '' ;
336338 }
337339
338340 var canonical_url = uri . href ;
@@ -368,12 +370,18 @@ function onBeforeRequest(details) {
368370 }
369371 }
370372
371- if ( newuristr && using_credentials_in_url ) {
372- // re-insert userpass info which was stripped temporarily
373- const uri_with_credentials = new URL ( newuristr ) ;
374- uri_with_credentials . username = tmp_user ;
375- uri_with_credentials . password = tmp_pass ;
376- newuristr = uri_with_credentials . href ;
373+ if ( using_credentials_in_url ) {
374+ const canonical_url_with_credentials = new URL ( canonical_url ) ;
375+ canonical_url_with_credentials . username = tmp_user ;
376+ canonical_url_with_credentials . password = tmp_pass ;
377+ canonical_url = canonical_url_with_credentials . href ;
378+ if ( newuristr ) {
379+ // re-insert userpass info which was stripped temporarily
380+ const uri_with_credentials = new URL ( newuristr ) ;
381+ uri_with_credentials . username = tmp_user ;
382+ uri_with_credentials . password = tmp_pass ;
383+ newuristr = uri_with_credentials . href ;
384+ }
377385 }
378386
379387 // In Switch Planner Mode, record any non-rewriteable
0 commit comments