@@ -69,6 +69,8 @@ function listener(details) {
6969 let filter = browser . webRequest . filterResponseData ( details . requestId ) ;
7070
7171 const queryString = new URL ( details . url ) . searchParams ;
72+ const originParams = new URLSearchParams ( details . originUrl . split ( '?' ) . slice ( 1 ) . join ( '?' ) ) ;
73+
7274 // Parse some params for container name
7375 let accountRole = queryString . get ( "role_name" ) ;
7476 let accountNumber = queryString . get ( "account_id" ) ;
@@ -93,7 +95,7 @@ function listener(details) {
9395 for ( const [ key , value ] of Object . entries ( params ) ) {
9496 name = name . replace ( key , value ) ;
9597 }
96-
98+ let originDestination = originParams . get ( "destination" ) ;
9799 let str = '' ;
98100 let decoder = new TextDecoder ( "utf-8" ) ;
99101 let encoder = new TextEncoder ( ) ;
@@ -114,8 +116,17 @@ function listener(details) {
114116 // If we have a sign-in token, hijack this into a container
115117 if ( object . signInToken ) {
116118 let destination = object . destination ;
117- if ( ! destination ) {
118- destination = "https://console.aws.amazon.com" ;
119+ if ( ! originDestination ) {
120+ if ( ! object . destination ) {
121+ if ( object . signInFederationLocation . includes ( "amazonaws-us-gov.com" ) ) {
122+ destination = "https://console.amazonaws-us-gov.com" ;
123+ } else {
124+ destination = "https://console.aws.amazon.com" ;
125+ }
126+ }
127+ }
128+ else {
129+ destination = originDestination ;
119130 }
120131
121132 // Generate our federation URI and open it in a container
0 commit comments