Skip to content

Commit

Permalink
Change same domain logic to respect second+ level domains
Browse files Browse the repository at this point in the history
Part of #92
  • Loading branch information
stoically committed Mar 16, 2018
1 parent 6eead5b commit 1cbf000
Show file tree
Hide file tree
Showing 4 changed files with 834 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"glob-to-regexp": "^0.4.0",
"jquery": "^3.3.1",
"p-queue": "^2.3.0",
"psl": "^1.1.25",
"semantic-ui": "^2.3.0",
"semver-compare": "^1.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions src/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"tmp": false,
"debug": false,
"lib": false,
"psl": false,
"log": false,
"delay": false,
"globToRegexp": false,
Expand Down
10 changes: 1 addition & 9 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,7 @@ class TemporaryContainers {


sameDomain(origin, target) {
const splittedTarget = target.split('.');
const checkHostname = '.' + (splittedTarget.splice(-2).join('.'));
const dottedOrigin = '.' + origin;
if (target.length > 1 &&
(dottedOrigin.endsWith(checkHostname) ||
checkHostname.endsWith(dottedOrigin))) {
return true;
}
return false;
return psl.parse(origin).domain === psl.parse(target).domain;
}


Expand Down
832 changes: 831 additions & 1 deletion src/background/lib.js

Large diffs are not rendered by default.

0 comments on commit 1cbf000

Please sign in to comment.