Skip to content

Commit b562345

Browse files
authored
Fix name param (#20)
* Use URL parsing to get correct account details * Housekeeping: await promises where appropriate * Bump version
1 parent 8186b0e commit b562345

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

containerize.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ function listener(details) {
6868

6969
let filter = browser.webRequest.filterResponseData(details.requestId);
7070

71-
let queryString = new URLSearchParams(details.url.split("?")[1]);
71+
const queryString = new URL(details.url).searchParams;
7272
// Parse some params for container name
7373
let accountRole = queryString.get("role_name");
7474
let accountNumber = queryString.get("account_id");
7575

7676
// pull subdomain for folks that might have multiple SSO
7777
// portals that have access to the same account and role names
78-
let host = /:\/\/([^\/]+)/.exec(details.originUrl)[1];
78+
const host = new URL(details.originUrl).host;
7979
let subdomain = host.split(".")[0];
8080

8181
let params = {
@@ -123,19 +123,19 @@ function listener(details) {
123123

124124
const container = await prepareContainer({ name });
125125

126+
// get index of tab we're about to remove, put ours at that spot
127+
const tab = await browser.tabs.get(details.tabId);
128+
126129
const createTabParams = {
127130
cookieStoreId: container.cookieStoreId,
128131
url: url,
129-
pinned: false
132+
pinned: false,
133+
index: tab.index,
130134
};
131135

132-
// get index of tab we're about to remove, put ours at that spot
133-
const tab = await browser.tabs.get(details.tabId);
134-
135-
createTabParams.index = tab.index;
136-
browser.tabs.create(createTabParams);
136+
await browser.tabs.create(createTabParams);
137137

138-
browser.tabs.remove(details.tabId);
138+
await browser.tabs.remove(details.tabId);
139139
} else {
140140
filter.write(encoder.encode(str));
141141
}
@@ -281,9 +281,9 @@ async function samlListener(details) {
281281
index: tab.index,
282282
};
283283

284-
browser.tabs.create(createTabParams);
284+
await browser.tabs.create(createTabParams);
285285

286-
browser.tabs.remove(details.tabId);
286+
await browser.tabs.remove(details.tabId);
287287

288288
return { cancel: true };
289289
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "AWS SSO Containers",
4-
"version": "1.7",
4+
"version": "1.8",
55
"description": "Automatically places AWS SSO calls into containers.",
66
"browser_specific_settings": {
77
"gecko": {

0 commit comments

Comments
 (0)