diff --git a/.appveyor.yml b/.appveyor.yml index 7ab91bd..ce1fdde 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ build: off environment: matrix: - - nodejs_version: '12' + - nodejs_version: '14' install: - ps: Install-Product node $env:nodejs_version diff --git a/.circleci/config.yml b/.circleci/config.yml index 3a96fd3..5a645a1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,9 +1,9 @@ version: 2 jobs: - build: + Build: docker: - - image: circleci/node:12 + - image: circleci/node:14 steps: - checkout - run: npm install @@ -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 diff --git a/.gitignore b/.gitignore index c086378..50d8e07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.zip node_modules +reports .DS_Store diff --git a/.travis.yml b/.travis.yml index 863e648..350edae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: - node_js node_js: - - "12" + - "14" diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c2bf9b..eb1b72f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index e9557c7..f820696 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/index.js b/test/index.js index 54281c9..28e943f 100644 --- a/test/index.js +++ b/test/index.js @@ -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/'; diff --git a/webextension/index.js b/webextension/index.js index c5840ec..13d467a 100644 --- a/webextension/index.js +++ b/webextension/index.js @@ -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); @@ -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 diff --git a/webextension/manifest.json b/webextension/manifest.json index 6f49947..278438f 100644 --- a/webextension/manifest.json +++ b/webextension/manifest.json @@ -38,5 +38,5 @@ "*://workable.com/", "*://www.youtube.com/" ], - "version": "5.0.0" + "version": "5.1.0" }