Skip to content

Commit

Permalink
Fix name param (#20)
Browse files Browse the repository at this point in the history
* Use URL parsing to get correct account details

* Housekeeping: await promises where appropriate

* Bump version
  • Loading branch information
cjallen88 committed Mar 27, 2024
1 parent 8186b0e commit b562345
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions containerize.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ function listener(details) {

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

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

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

let params = {
Expand Down Expand Up @@ -123,19 +123,19 @@ function listener(details) {

const container = await prepareContainer({ name });

// get index of tab we're about to remove, put ours at that spot
const tab = await browser.tabs.get(details.tabId);

const createTabParams = {
cookieStoreId: container.cookieStoreId,
url: url,
pinned: false
pinned: false,
index: tab.index,
};

// get index of tab we're about to remove, put ours at that spot
const tab = await browser.tabs.get(details.tabId);

createTabParams.index = tab.index;
browser.tabs.create(createTabParams);
await browser.tabs.create(createTabParams);

browser.tabs.remove(details.tabId);
await browser.tabs.remove(details.tabId);
} else {
filter.write(encoder.encode(str));
}
Expand Down Expand Up @@ -281,9 +281,9 @@ async function samlListener(details) {
index: tab.index,
};

browser.tabs.create(createTabParams);
await browser.tabs.create(createTabParams);

browser.tabs.remove(details.tabId);
await browser.tabs.remove(details.tabId);

return { cancel: true };
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "AWS SSO Containers",
"version": "1.7",
"version": "1.8",
"description": "Automatically places AWS SSO calls into containers.",
"browser_specific_settings": {
"gecko": {
Expand Down

0 comments on commit b562345

Please sign in to comment.