File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,13 @@ Parse urls from css file
13
13
14
14
## Usage
15
15
``` javascript
16
- var parseCssUrls = require (' css-url-parser' );
16
+ var parseCssUrls = require (' css-url-parser' );
17
17
18
18
var css = ' @import "a.css"; .image { background-image: url(images/img.png); }' ;
19
19
var cssUrls = parseCssUrls (css);
20
20
21
21
console .log (cssUrls); // [ 'a.css', 'images/img.png' ]
22
22
```
23
23
24
+ It ignores duplicated urls and base64 encoded resources.
25
+ If no urls found empty array will be returned.
Original file line number Diff line number Diff line change @@ -50,13 +50,23 @@ var should = require('should')
50
50
' ;
51
51
52
52
var urls = parseCssUrls ( text ) ;
53
+ urls . should . be . instanceof ( Array ) ;
53
54
urls . should . be . empty ;
54
55
} ) ;
55
56
56
57
it ( 'should ignore empty urls' , function ( ) {
57
58
var text = 'div.image { background-image: url(""); } ' ;
58
59
59
60
var urls = parseCssUrls ( text ) ;
61
+ urls . should . be . instanceof ( Array ) ;
62
+ urls . should . be . empty ;
63
+ } ) ;
64
+
65
+ it ( 'should return empty array if no urls were found' , function ( ) {
66
+ var text = 'no css urls should be found in this text' ;
67
+
68
+ var urls = parseCssUrls ( text ) ;
69
+ urls . should . be . instanceof ( Array ) ;
60
70
urls . should . be . empty ;
61
71
} ) ;
62
72
} ) ;
You can’t perform that action at this time.
0 commit comments