@@ -82,6 +82,80 @@ describe('Parse css urls', function(){
82
82
urls . should . containEql ( ' a.css' ) ;
83
83
} ) ;
84
84
85
+ it ( 'should handle urls without extension' , function ( ) {
86
+ var text = '.image { background: url("image-without-ext"); } ' ;
87
+ var urls = parseCssUrls ( text ) ;
88
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
89
+ urls . should . containEql ( 'image-without-ext' ) ;
90
+ } ) ;
91
+
92
+ describe ( 'quotes' , function ( ) {
93
+ it ( 'should find url without quotes' , function ( ) {
94
+ var text = '.image { background: url(bg.jpg); } ' ;
95
+ var urls = parseCssUrls ( text ) ;
96
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
97
+ urls . should . containEql ( 'bg.jpg' ) ;
98
+ } ) ;
99
+
100
+ it ( 'should find url containing single quotes inside double quotes' , function ( ) {
101
+ var text = '.image { background: url("bg\'1.jpg"); }' ;
102
+ var urls = parseCssUrls ( text ) ;
103
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
104
+ urls . should . containEql ( 'bg\'1.jpg' ) ;
105
+ } ) ;
106
+
107
+ it ( 'should find url containing double quotes inside single quotes' , function ( ) {
108
+ var text = '.image { background: url(\'bg" 23\'); }' ;
109
+ var urls = parseCssUrls ( text ) ;
110
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
111
+ urls . should . containEql ( 'bg" 23' ) ;
112
+ } ) ;
113
+
114
+ it ( 'should find import without quotes' , function ( ) {
115
+ var text = '@import new.css;' ;
116
+ var urls = parseCssUrls ( text ) ;
117
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
118
+ urls . should . containEql ( 'new.css' ) ;
119
+ } ) ;
120
+
121
+ it ( 'should find import containing single quotes inside double quotes' , function ( ) {
122
+ var text = '@import "new\'11\'.css";' ;
123
+ var urls = parseCssUrls ( text ) ;
124
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
125
+ urls . should . containEql ( 'new\'11\'.css' ) ;
126
+ } ) ;
127
+
128
+ it ( 'should find import containing double quotes inside single quotes' , function ( ) {
129
+ var text = '@import \'new" _2_".css\';' ;
130
+ var urls = parseCssUrls ( text ) ;
131
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
132
+ urls . should . containEql ( 'new" _2_".css' ) ;
133
+ } ) ;
134
+ } ) ;
135
+
136
+ describe ( 'parentheses' , function ( ) {
137
+ it ( 'should handle parentheses inside url in filename' , function ( ) {
138
+ var text = '.image { background: url("test (2).png"); } ' ;
139
+ var urls = parseCssUrls ( text ) ;
140
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
141
+ urls . should . containEql ( 'test (2).png' ) ;
142
+ } ) ;
143
+
144
+ it ( 'should handle parentheses inside url in extension' , function ( ) {
145
+ var text = '.image { background: url(\'test.png (2)\'); } ' ;
146
+ var urls = parseCssUrls ( text ) ;
147
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
148
+ urls . should . containEql ( 'test.png (2)' ) ;
149
+ } ) ;
150
+
151
+ it ( 'should handle parentheses inside @import' , function ( ) {
152
+ var text = '@import "import)).css" ' ;
153
+ var urls = parseCssUrls ( text ) ;
154
+ urls . should . be . instanceof ( Array ) . and . have . lengthOf ( 1 ) ;
155
+ urls . should . containEql ( 'import)).css' ) ;
156
+ } ) ;
157
+ } ) ;
158
+
85
159
describe ( 'comments' , function ( ) {
86
160
it ( 'should ignore comments and return empty array if there are only comments in text' , function ( ) {
87
161
var text = '\
0 commit comments