Skip to content

normalize urls before passing them to Chromium #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"sirv": "^1.0.7"
},
"dependencies": {
"normalize-url": "^5.3.0",
"puppeteer": "^5.5.0"
},
"eslintConfig": {
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global document */
const puppeteer = require('puppeteer')
const normalizeUrl = require('normalize-url')

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

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