@@ -219,9 +219,9 @@ _run_resolver({useRelativeUrls}) {
219
219
expectedForHttpScheme: 'http://www.google.com/something' );
220
220
221
221
testBothSchemes (
222
- urlToResolve: '''http://www.google.com/something/foo('bar) ''' ,
223
- expectedForPackageScheme: '''http://www.google.com/something/foo('bar) ''' ,
224
- expectedForHttpScheme: '''http://www.google.com/something/foo('bar) ''' );
222
+ urlToResolve: '''http://www.google.com/something/foo('bar%29 ''' ,
223
+ expectedForPackageScheme: '''http://www.google.com/something/foo('bar%29 ''' ,
224
+ expectedForHttpScheme: '''http://www.google.com/something/foo('bar%29 ''' );
225
225
226
226
testBothSchemes (
227
227
urlToResolve: 'HTTP://LOCALHOST/a/b/image4.png' ,
@@ -242,7 +242,7 @@ void main() {
242
242
_run_resolver (useRelativeUrls: false );
243
243
});
244
244
245
- describe ('url_resolver uri rewrite ' , () {
245
+ describe ('url_resolver' , () {
246
246
ResourceUrlResolver resolver;
247
247
248
248
beforeEach ((){
@@ -252,47 +252,60 @@ void main() {
252
252
.forTests (typeMapper, config, 'http://localhost' );
253
253
});
254
254
255
- it ('should not rewrite absolute paths, empty paths and custom schemas' ,
256
- () {
257
- Uri baseUri = new Uri ();
258
- expect (resolver.combine (baseUri, "/test" )).toEqual ("/test" );
259
- expect (resolver.combine (baseUri, "#" )).toEqual ("#" );
260
- expect (resolver.combine (baseUri, "#abc" )).toEqual ("#abc" );
261
- expect (resolver.combine (baseUri, "" )).toEqual ("" );
262
- expect (resolver.combine (baseUri, "javascript:void()" ))
263
- .toEqual ("javascript:void()" );
264
- expect (resolver.combine (baseUri, "data:uriloijoi" ))
265
- .toEqual ("data:uriloijoi" );
266
- });
255
+ describe ('uri rewrite' , () {
256
+ it ('should not rewrite absolute paths, empty paths and custom schemas' ,
257
+ () {
258
+ Uri baseUri = new Uri ();
259
+ expect (resolver.combine (baseUri, "/test" )).toEqual ("/test" );
260
+ expect (resolver.combine (baseUri, "#" )).toEqual ("#" );
261
+ expect (resolver.combine (baseUri, "#abc" )).toEqual ("#abc" );
262
+ expect (resolver.combine (baseUri, "" )).toEqual ("" );
263
+ expect (resolver.combine (baseUri, "javascript:void()" ))
264
+ .toEqual ("javascript:void()" );
265
+ expect (resolver.combine (baseUri, "data:uriloijoi" ))
266
+ .toEqual ("data:uriloijoi" );
267
+ });
267
268
268
- it ('should rewrite package relative base uris' , () {
269
- Uri baseUri = Uri .parse ("/packages/a.b.c/comp.dart" );
270
- expect (resolver.combine (baseUri, "test.jpg" ))
271
- .toEqual ("/packages/a.b.c/test.jpg" );
272
- expect (resolver.combine (baseUri, "test/test.jpg" ))
273
- .toEqual ("/packages/a.b.c/test/test.jpg" );
274
- });
269
+ it ('should rewrite package relative base uris' , () {
270
+ Uri baseUri = Uri .parse ("/packages/a.b.c/comp.dart" );
271
+ expect (resolver.combine (baseUri, "test.jpg" ))
272
+ .toEqual ("/packages/a.b.c/test.jpg" );
273
+ expect (resolver.combine (baseUri, "test/test.jpg" ))
274
+ .toEqual ("/packages/a.b.c/test/test.jpg" );
275
+ });
275
276
276
- it ('should rewrite current base uri to absolute without scheme' , () {
277
- Uri baseUri = Uri .parse ("http://localhost/test/test2/test.jgp" );
278
- expect (resolver.combine (baseUri, 'test4.jpg' ))
279
- .toEqual ('/test/test2/test4.jpg' );
280
- });
277
+ it ('should rewrite current base uri to absolute without scheme' , () {
278
+ Uri baseUri = Uri .parse ("http://localhost/test/test2/test.jgp" );
279
+ expect (resolver.combine (baseUri, 'test4.jpg' ))
280
+ .toEqual ('/test/test2/test4.jpg' );
281
+ });
281
282
282
- it ('should rewrite external URIs to contain full scheme' , () {
283
- Uri baseUri = Uri .parse ("http://foo.com/test/test.jgp" );
284
- expect (resolver.combine (baseUri, 'test4.jpg' ))
285
- .toEqual ('http://foo.com/test/test4.jpg' );
286
- });
283
+ it ('should rewrite external URIs to contain full scheme' , () {
284
+ Uri baseUri = Uri .parse ("http://foo.com/test/test.jgp" );
285
+ expect (resolver.combine (baseUri, 'test4.jpg' ))
286
+ .toEqual ('http://foo.com/test/test4.jpg' );
287
+ });
288
+
289
+ it ('should not remove hash from URI' , () {
290
+ Uri baseUri = Uri .parse ("/packages/a.b.c/comp.dart" );
291
+ expect (resolver.combine (baseUri, "test.jpg#1234" ))
292
+ .toEqual ("/packages/a.b.c/test.jpg#1234" );
287
293
288
- it ('should not remove hash from URI' , () {
289
- Uri baseUri = Uri .parse ("/packages/a.b.c/comp.dart" );
290
- expect (resolver.combine (baseUri, "test.jpg#1234" ))
291
- .toEqual ("/packages/a.b.c/test.jpg#1234" );
294
+ Uri externalUri = Uri .parse ("http://foo.com/test/test.jgp" );
295
+ expect (resolver.combine (externalUri, 'test4.jpg#1234' ))
296
+ .toEqual ('http://foo.com/test/test4.jpg#1234' );
297
+ });
298
+ });
292
299
293
- Uri externalUri = Uri .parse ("http://foo.com/test/test.jgp" );
294
- expect (resolver.combine (externalUri, 'test4.jpg#1234' ))
295
- .toEqual ('http://foo.com/test/test4.jpg#1234' );
300
+ describe ('css rewrite' , () {
301
+ it ('should not rewrite two urls at once' , () {
302
+ Uri baseUri = Uri .parse ('/test/' );
303
+ var result = resolver.resolveCssText (
304
+ ".a{image:url('a.png')}"
305
+ ".b{image:url('b.png')}" , baseUri);
306
+ expect (result).toEqual (".a{image:url('/test/a.png')}"
307
+ ".b{image:url('/test/b.png')}" );
308
+ });
296
309
});
297
310
});
298
311
}
0 commit comments