Skip to content

Commit

Permalink
v5.1.0 - 2020-04-28
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornstar committed Apr 28, 2020
1 parent 5640e30 commit 4cae997
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ build: off

environment:
matrix:
- nodejs_version: '12'
- nodejs_version: '14'

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
36 changes: 25 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2

jobs:
build:
Build:
docker:
- image: circleci/node:12
- image: circleci/node:14
steps:
- checkout
- run: npm install
Expand All @@ -12,25 +12,39 @@ jobs:
paths:
- node_modules

test:
Lint:
docker: circleci/node:14
steps:
- checkout
- restore_cache:
keys:
- node_modules-{{ .Branch }}-{{ .Revision }}
- run: mkdir -p reports
- run: ./node_modules/.bin/eslint webextension test --format=junit | tee reports/eslint.xml
- store_test_results:
path: reports

Mocha:
docker:
- image: circleci/node:12
- image: circleci/node:14
steps:
- checkout
- restore_cache:
keys:
- node_modules-{{ .Branch }}-{{ .Revision }}
- run: |
mkdir -p reports
./node_modules/.bin/mocha test --reporter=xunit | tee reports/test.xml
- run: mkdir -p reports
- run: ./node_modules/.bin/mocha test --reporter=xunit | tee reports/mocha.xml
- store_test_results:
path: reports

workflows:
version: 2
build_and_test:
Build, Lint, and Mocha:
jobs:
- build
- test:
- Build
- Lint:
requires:
- Build
- Mocha:
requires:
- build
- Build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.zip
node_modules
reports
.DS_Store
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language:
- node_js
node_js:
- "12"
- "14"
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Intercept Redirect

## v5.1.0 - 2020-04-28
- Ensure a protocol is in the URL (Fixes #12)
- De-emphasize the Chrome Web Store in the README (Fixes #13)
- Update devDependency `mocha` from `v7.1.0` to `v7.1.2`
- Try using node `v14` in all three CI
- CircleCI can run lint and mocha in parallel
- Add reports to `.gitignore`

## v5.0.0 - 2020-04-25
- Add `outgoing.prod.mozaws.net`
- Use new format for parsing
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@bjornstar/intercept-redirect",
"version": "5.0.0",
"version": "5.1.0",
"description": "Skip tracking redirects that serve no purpose other than to waste your valuable time.",
"main": "webextension/index.js",
"dependencies": {},
"devDependencies": {
"eslint": "^6.8.0",
"mocha": "^7.1.0"
"mocha": "^7.1.2"
},
"scripts": {
"build": "./build.sh",
Expand Down
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ describe('analyzeURL', () => {
});
});

describe('The redirect should begin with a protocol', () => {
it('https:// gets prepended if there is no protocol', () => {
const url = 'https://steamcommunity.com/linkfilter/?url=bjornstar.com';

const { redirectUrl } = analyzeURL({ url });

assert.strictEqual(redirectUrl.indexOf('https://'), 0);
});
});

describe('No redirect for sites that are implemented but the URLs do not match', () => {
const url = 'https://www.google.com/';

Expand Down
7 changes: 6 additions & 1 deletion webextension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ const URL = typeof window === 'object' ? window.URL : require('url').URL;

const matchPatternToRegex = mp => `^${mp.replace(/\./, '\\.').replace(/\*/, '.*')}`;

const ensureProtocol = s => {
const prepend = /^.*:\/\//.test(s) ? '' : 'https://';
return `${prepend}${s}`;
};

const extract = (url, value) => {
const re = new RegExp(matchPatternToRegex(url));
return url => re.test(url.pathname) && value(url);
Expand Down Expand Up @@ -150,7 +155,7 @@ function analyzeURL(request) {

const redirectUrl = find(redirectExtractors[host], url);

return redirectUrl && { redirectUrl };
return redirectUrl && { redirectUrl: ensureProtocol(redirectUrl) };
}

// Only runs in the browser
Expand Down
2 changes: 1 addition & 1 deletion webextension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
"*://workable.com/",
"*://www.youtube.com/"
],
"version": "5.0.0"
"version": "5.1.0"
}

0 comments on commit 4cae997

Please sign in to comment.