Skip to content

Commit

Permalink
Merge pull request #243 from tilfinltd/fix/judge-local
Browse files Browse the repository at this point in the history
Fix to judge isLocal (instead of isGlobal)
  • Loading branch information
tilfin committed Jan 30, 2022
2 parents 9a7ceff + b0dd5ac commit 117a6ac
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ function loadFormList(curURL, userInfo, tabId) {
}

function renderRoleList(profiles, tabId, curURL, options) {
const { url, region, notGlobal } = getCurrentUrlandRegion(curURL)
const { url, region, isLocal } = getCurrentUrlandRegion(curURL)
const listItemOnSelect = function(data) {
if (options.signinEndpointInHere && notGlobal) data.actionSubdomain = region;
if (options.signinEndpointInHere && isLocal) data.actionSubdomain = region;
sendSwitchRole(tabId, data);
}
const list = document.getElementById('roleList');
Expand Down Expand Up @@ -180,6 +180,13 @@ function getCurrentUrlandRegion(aURL) {
let region = '';
const md = aURL.search.match(/region=([a-z\-1-9]+)/);
if (md) region = md[1];
const notGlobal = /^[a-z]{2}\-[a-z]+\-[1-9]\.console\.aws/.test(aURL.host);
return { url, region, notGlobal }

let isLocal = false;
const mdsd = aURL.host.match(/^(([a-z]{2}\-[a-z]+\-[1-9])\.)?console\.aws/);
if (mdsd) {
const [,, cr = 'us-east-1'] = mdsd;
if (cr === region) isLocal = true;
}

return { url, region, isLocal }
}

0 comments on commit 117a6ac

Please sign in to comment.