Skip to content

Commit 33d0ded

Browse files
bartvenemanBart Veneman
andauthored
normalize urls before passing them to Chromium (projectwallace#39)
Co-authored-by: Bart Veneman <bart.veneman@drukwerkdeal.nl>
1 parent 57cfc1b commit 33d0ded

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

package-lock.json

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"sirv": "^1.0.7"
3232
},
3333
"dependencies": {
34+
"normalize-url": "^5.3.0",
3435
"puppeteer": "^5.5.0"
3536
},
3637
"eslintConfig": {

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* global document */
22
const puppeteer = require('puppeteer')
3+
const normalizeUrl = require('normalize-url')
34

45
function InvalidUrlError({url, statusCode, statusText}) {
56
this.name = 'InvalidUrlError'
@@ -20,6 +21,7 @@ module.exports = async (url, {waitUntil = 'networkidle0', origins = 'exclude'} =
2021
// Create a new page and navigate to it
2122
const page = await browser.newPage()
2223
await page.coverage.startCSSCoverage()
24+
url = normalizeUrl(url, {stripWWW: false})
2325
const response = await page.goto(url, {waitUntil})
2426

2527
// Make sure that we only try to extract CSS from valid pages.

0 commit comments

Comments
 (0)