Skip to content

Commit

Permalink
Chore: Remove same-origin dependency
Browse files Browse the repository at this point in the history
Fix #879
Close #916
  • Loading branch information
sarvaje authored and alrra committed Mar 22, 2018
1 parent e410953 commit 7ca95d4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions packages/rule-disown-opener/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
},
"dependencies": {
"caniuse-api": "^2.0.0",
"pluralize": "^7.0.0",
"same-origin": "^0.1.1"
"pluralize": "^7.0.0"
},
"description": "sonarwhal rule that checks if external links disown the opener",
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/rule-disown-opener/src/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import { URL } from 'url';

import { isSupported } from 'caniuse-api';
import * as pluralize from 'pluralize';
import * as sameOrigin from 'same-origin';

import { Category } from 'sonarwhal/dist/src/lib/enums/category';
import { cutString, isRegularProtocol } from 'sonarwhal/dist/src/lib/utils/misc';
import { cutString, isRegularProtocol, sameOrigin } from 'sonarwhal/dist/src/lib/utils/misc';
import { debug as d } from 'sonarwhal/dist/src/lib/utils/debug';
import { IAsyncHTMLElement, ElementFound, IRule, RuleMetadata } from 'sonarwhal/dist/src/lib/types';
import { normalizeString } from 'sonarwhal/dist/src/lib/utils/misc';
Expand Down
5 changes: 5 additions & 0 deletions packages/sonarwhal/src/lib/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ const getSonarwhalPackage = () => {
return require(path.join(__dirname, '../../../../package.json'));
};

const sameOrigin = (url1: string, url2: string): boolean => {
return new URL(url1).origin === new URL(url2).origin;
};

export {
cutString,
delay,
Expand Down Expand Up @@ -375,6 +379,7 @@ export {
readFileAsync,
requestJSONAsync,
requestAsync,
sameOrigin,
toCamelCase,
writeFileAsync
};
4 changes: 0 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6671,10 +6671,6 @@ safe-regex@^1.1.0:
dependencies:
ret "~0.1.10"

same-origin@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/same-origin/-/same-origin-0.1.1.tgz#c2287d3192577df517acbbd6d1451a9c3c3914f5"

samsam@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50"
Expand Down

0 comments on commit 7ca95d4

Please sign in to comment.