fix: resolving already resolved HTTP links in file

Also includes tests
This commit is contained in:
Felix Akkermans 2015-11-13 00:05:20 +01:00 committed by Remy Sharp
parent 747836d3e0
commit cbcd398182
3 changed files with 17 additions and 1 deletions

View File

@ -275,11 +275,16 @@ function resolve(from, to) {
from = this.url;
}
// don't resolve data urls
// don't resolve data urls (already inlined)
if (to.indexOf('data:') === 0) {
return to;
}
// don't resolve http(s) urls (no need to resolve)
if (to.indexOf('http:') === 0 || to.indexOf('https:') === 0) {
return to;
}
if (!this.isFile || from.indexOf('http') === 0) {
return require('url').resolve(from, to);
} else {

1
test/fixtures/image-ext.result.html vendored Normal file
View File

@ -0,0 +1 @@
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>External image (or local but already resolved source URL)</title> </head> <body> <img src="data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs="> </body> </html>

10
test/fixtures/image-ext.src.html vendored Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>External image (or local but already resolved source URL)</title>
</head>
<body>
<img src="http://localhost:54321/1x1.gif">
</body>
</html>