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
1313
1414## Usage
1515``` javascript
16- var parseCssUrls = require (' css-url-parser' );
16+ var parseCssUrls = require (' css-url-parser' );
1717
1818var css = ' @import "a.css"; .image { background-image: url(images/img.png); }' ;
1919var cssUrls = parseCssUrls (css);
2020
2121console .log (cssUrls); // [ 'a.css', 'images/img.png' ]
2222```
2323
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')
5050 ' ;
5151
5252 var urls = parseCssUrls ( text ) ;
53+ urls . should . be . instanceof ( Array ) ;
5354 urls . should . be . empty ;
5455 } ) ;
5556
5657 it ( 'should ignore empty urls' , function ( ) {
5758 var text = 'div.image { background-image: url(""); } ' ;
5859
5960 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 ) ;
6070 urls . should . be . empty ;
6171 } ) ;
6272 } ) ;
You can’t perform that action at this time.
0 commit comments