@@ -10,6 +10,10 @@ describe('node-detective-postcss', () => {
1010 assert ( '@import "foo.css"' , [ 'foo.css' ] ) ;
1111 } ) ;
1212
13+ it ( 'works with single quotes' , ( ) => {
14+ assert ( "@import 'foo.css'" , [ 'foo.css' ] ) ;
15+ } ) ;
16+
1317 describe ( 'url()' , ( ) => {
1418 it ( 'works with url()' , ( ) => {
1519 assert ( '@import url("navigation.css");' , [ 'navigation.css' ] ) ;
@@ -57,6 +61,10 @@ describe('node-detective-postcss', () => {
5761 assert ( '@import url("//example.com/style.css");' , [ ] ) ;
5862 } ) ;
5963
64+ it ( 'ignores protocol-relative URLs without url()' , ( ) => {
65+ assert ( '@import "//example.com/style.css"' , [ ] ) ;
66+ } ) ;
67+
6068 it ( 'does not touch the paths' , ( ) => {
6169 assert ( '@import "../../././bla.css"' , [ '../../././bla.css' ] ) ;
6270 } ) ;
@@ -89,6 +97,10 @@ describe('node-detective-postcss', () => {
8997 ] ) ;
9098 } ) ;
9199
100+ it ( 'ignores absolute URLs' , ( ) => {
101+ assert ( "@value primary from 'https://example.com/colors.css';" , [ ] ) ;
102+ } ) ;
103+
92104 it ( 'leaves simple definitions alone' , ( ) => {
93105 assert ( '@value mine: #fff;' , [ ] ) ;
94106 } ) ;
@@ -135,6 +147,24 @@ describe('node-detective-postcss', () => {
135147 assert ( '@value x: url(bummer.png)' , [ 'bummer.png' ] , { url : true } ) ;
136148 } ) ;
137149
150+ it ( 'ignores absolute urls' , ( ) => {
151+ assert ( '.x { background: url(https://example.com/img.png) }' , [ ] , {
152+ url : true ,
153+ } ) ;
154+ } ) ;
155+
156+ it ( 'ignores protocol-relative urls' , ( ) => {
157+ assert ( '.x { background: url(//example.com/img.png) }' , [ ] , {
158+ url : true ,
159+ } ) ;
160+ } ) ;
161+
162+ it ( 'finds multiple url() in one declaration' , ( ) => {
163+ assert ( '.x { background: url(a.png), url(b.png) }' , [ 'a.png' , 'b.png' ] , {
164+ url : true ,
165+ } ) ;
166+ } ) ;
167+
138168 it ( 'ignores base64 data: urls' , ( ) => {
139169 assert (
140170 '.x { background: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}' ,
@@ -144,8 +174,8 @@ describe('node-detective-postcss', () => {
144174
145175 it ( 'ignores SVG data: urls' , ( ) => {
146176 const css = `svg {
147- -webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 32 32" width="32" height="32" xmlns="http://www.w3.org/2000/svg"><defs><mask id="mask"><rect x="0" y="0" width="32" height="32" fill="#fff"/><rect x="14" y="-10" width="40" height="20" rx="10" fill="#000"/></mask></defs><rect x="0" y="0" width="32" height="32" mask="url(#mask)"/></svg>');
148- }` ;
177+ -webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 32 32" width="32" height="32" xmlns="http://www.w3.org/2000/svg"><defs><mask id="mask"><rect x="0" y="0" width="32" height="32" fill="#fff"/><rect x="14" y="-10" width="40" height="20" rx="10" fill="#000"/></mask></defs><rect x="0" y="0" width="32" height="32" mask="url(#mask)"/></svg>');
178+ }` ;
149179 assert ( css , [ ] ) ;
150180 } ) ;
151181 } ) ;
0 commit comments