Skip to content

Commit 3e1bea2

Browse files
committed
try ever a fallback on data-uri. #54
1 parent 07d1046 commit 3e1bea2

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/com/inet/lib/less/UrlUtils.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,9 @@ static void dataUri( CssFormatter formatter, String relativeUrlStr, final String
177177
try {
178178
input = formatter.getReaderFactory().openStream( url );
179179
} catch( Exception e ) {
180-
// try rewrite location if option "rewrite-urls" is "all" or "local"
181-
if( formatter.isRewriteUrl( "." ) ) {
182-
url = new URL( new URL( formatter.getBaseURL(), relativeUrlStr ), urlStr );
183-
input = formatter.getReaderFactory().openStream( url );
184-
} else {
185-
throw e;
186-
}
180+
// try rewrite location independent of option "rewrite-urls" for backward compatibility, this is not 100% compatible with Less CSS
181+
url = new URL( new URL( formatter.getBaseURL(), relativeUrlStr ), urlStr );
182+
input = formatter.getReaderFactory().openStream( url );
187183
}
188184
} catch( Exception e ) {
189185
boolean quote = urlString != urlStr;

test/com/inet/lib/less/RewriteUrls/off.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
.rule2 {
22
url1: url('../image.jpg');
3-
url2: url('../image.jpg');
3+
url2: url("data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg==");
44
url3: url('subfolder1/image.jpg');
55
url4: url("data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg==");
66
url5: url('../DoesNotExists.jpg');
77
url4: url('subfolder1/DoesNotExists.jpg');
88
}
99
.rule1 {
1010
url1: url('image.jpg');
11-
url2: url('image.jpg');
11+
url2: url("data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg==");
1212
url3: url('subfolder1/image.jpg');
1313
url4: url("data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg==");
1414
url5: url('DoesNotExists.jpg');

0 commit comments

Comments
 (0)