Skip to content

Commit

Permalink
fix(background): Fix adding custom integrations URLs (#1861)
Browse files Browse the repository at this point in the history
  • Loading branch information
rylek90 committed Oct 13, 2020
1 parent e313cc1 commit b35f36b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
20 changes: 3 additions & 17 deletions src/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2227,30 +2227,16 @@ window.TogglButton = {
},

extractDomain: async function (url, checkLogin = true) {
let domain;
if (checkLogin && !TogglButton.$user) {
return false;
}
// find & remove protocol (http, ftp, etc.) and get domain
if (url.indexOf('://') > -1) {
domain = url.split('/')[2];
} else {
domain = url.split('/')[0];
}

// remove www if needed
// domain = domain.replace("www.", "");

// remove /* from the end
domain = domain.split('/*')[0];

// find & remove port number
domain = domain.split(':')[0];
const hostname = new URL(url).hostname.replace('www.', '');
const file = await db.getOriginFileName(hostname);

const file = await db.getOriginFileName(domain);
return {
file: file,
origins: ['*://' + domain + '/*']
origins: ['*://' + hostname + '/*']
};
},

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ const Settings = {
}

Settings.$newPermission.value = text;
const domain = '*://' + Settings.$newPermission.value + '/';
const domain = '*://*.' + Settings.$newPermission.value + '/';
const permission = { origins: [domain] };

browser.permissions.request(permission)
Expand Down

0 comments on commit b35f36b

Please sign in to comment.