Skip to content

Commit

Permalink
Allow non-absolute urls as argument (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartveneman authored Jul 21, 2019
1 parent bb107e2 commit 912f85d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@
"got": "^9.6.0",
"import-jsx": "^2.0.0",
"ink": "^2.2.0",
"is-absolute-url": "^3.0.0",
"is-url-superb": "^3.0.0",
"meow": "^5.0.0",
"normalize-url": "^4.3.0",
"pretty-bytes": "^5.2.0",
"react": "^16.8.6",
"tinycolor2": "^1.4.1",
Expand Down
9 changes: 6 additions & 3 deletions src/get-css.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const isAbsoluteUrl = require('is-absolute-url')
const got = require('got')
const isUrl = require('is-url-superb')
const normalizeUrl = require('normalize-url')

module.exports = async (input, options = {}) => {
if (!isAbsoluteUrl(input)) {
if (!isUrl(input)) {
return input
}

const {body} = await got(`https://extract-css.now.sh/${input}`, {
const url = normalizeUrl(input, {stripWWW: false})

const {body} = await got(`https://extract-css.now.sh/${url}`, {
responseType: 'text',
resolveBodyOnly: true,
headers: {
Expand Down

0 comments on commit 912f85d

Please sign in to comment.