Skip to content

Commit ddd5848

Browse files
authored
Remove lodash dependency (#6)
1 parent 77b13c4 commit ddd5848

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

lib/css-parser.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var _ = require('lodash');
2-
31
var embeddedRegexp = /data:(.*?);base64,/;
42
var commentRegexp = /\/\*([\s\S]*?)\*\//g;
53
var urlsRegexp = /((?:@import\s+)?url\s*\(['"]?)(\S*?)(['"]?\s*\))|(@import\s+['"]?)([^;'"]+)/ig;
@@ -10,20 +8,23 @@ function isEmbedded (src) {
108

119
function getUrls (text) {
1210
var urls = [];
13-
var urlMatch;
11+
var urlMatch, url, isEmbeddedUrl, isDuplicatedUrl;
1412

1513
text = text.replace(commentRegexp, '');
1614

1715
while (urlMatch = urlsRegexp.exec(text)) {
1816
// Match 2 group if '[@import] url(path)', match 5 group if '@import path'
19-
urls.push(urlMatch[2]||urlMatch[5]);
17+
url = urlMatch[2] || urlMatch[5];
18+
19+
isEmbeddedUrl = isEmbedded(url);
20+
isDuplicatedUrl = urls.indexOf(url) !== -1;
21+
22+
if (url && !isEmbeddedUrl && !isDuplicatedUrl) {
23+
urls.push(url);
24+
}
2025
}
2126

22-
return _.chain(urls)
23-
.compact()
24-
.reject(isEmbedded)
25-
.uniq()
26-
.value();
27+
return urls;
2728
}
2829

2930
module.exports = getUrls;

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
"homepage": "https://github.com/s0ph1e/node-css-url-parser",
2626
"author": "s0ph1e",
2727
"license": "MIT",
28-
"dependencies": {
29-
"lodash": "^4.0.0"
30-
},
3128
"devDependencies": {
3229
"coveralls": "^2.11.2",
3330
"istanbul": "^0.4.5",

0 commit comments

Comments
 (0)