Skip to content
This repository was archived by the owner on Jan 27, 2019. It is now read-only.

Commit af0cf1a

Browse files
committed
Merge pull request #33 from johnotander/dont-strip-www
Dont strip www and validate the url
2 parents b62b2a9 + 2644e27 commit af0cf1a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
var q = require('q');
44
var isCss = require('is-css');
5+
var isBlank = require('is-blank')
6+
var isUrl = require('is-url-superb')
57
var request = require('request');
68
var cheerio = require('cheerio');
79
var normalizeUrl = require('normalize-url');
@@ -20,7 +22,11 @@ module.exports = function(url, options){
2022
options.timeout = options.timeout || 5000;
2123
options.gzip = true;
2224

23-
url = normalizeUrl(url);
25+
if (typeof url !== 'string' || isBlank(url) || !isUrl(url)) {
26+
throw new TypeError('get-css expected a url as a string')
27+
}
28+
29+
url = normalizeUrl(url, { stripWWW: false });
2430
options.url = url;
2531

2632
if (options.ignoreCerts) {

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "get-css",
3-
"version": "1.1.1",
3+
"version": "1.2.0",
44
"description": "Get CSS from a URL",
55
"main": "index.js",
66
"scripts": {
@@ -12,13 +12,15 @@
1212
"author": "Brent Jackson",
1313
"license": "MIT",
1414
"dependencies": {
15-
"cheerio": "^0.18.0",
15+
"cheerio": "^0.19.0",
1616
"commander": "^2.7.1",
17+
"is-blank": "^1.0.0",
1718
"is-css": "^1.0.0",
19+
"is-url-superb": "^2.0.0",
1820
"normalize-url": "^1.2.0",
1921
"q": "^1.1.2",
2022
"request": "^2.48.0",
21-
"resolve-css-import-urls": "0.0.2",
23+
"resolve-css-import-urls": "0.0.3",
2224
"strip-html-comments": "0.0.2"
2325
},
2426
"devDependencies": {

0 commit comments

Comments
 (0)