Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

0.0.4 (correct URL resolving)

  • Loading branch information...
commit e73ec61844d9d0eb5f93cbc19388c984da8d86e4 1 parent 4890bfa
@Panya authored
Showing with 7 additions and 6 deletions.
  1. +1 −1  VERSION
  2. +5 −4 lib/durilka.js
  3. +1 −1  package.json
View
2  VERSION
@@ -1 +1 @@
-Durilka v0.0.3
+Durilka v0.0.4
View
9 lib/durilka.js
@@ -67,7 +67,7 @@ function normalizeUri(uri, baseUrl) {
} else if (/^https?/.test(uri)) {
normUri = uri;
} else {
- normUri = baseUrl ? baseUrl + uri : uri;
+ normUri = baseUrl ? url.resolve(baseUrl, uri) : uri;
}
}
return normUri;
@@ -90,16 +90,17 @@ function encodeImage(uri, callback) {
request.on('response', function(response) {
var type = response.headers['content-type'],
- prefix = 'data:' + type + ';base64,';
+ prefix = 'data:' + type + ';base64,', status;
response.body = [];
response.setEncoding('binary');
response.on('data', function(chunk) {
- if (response.statusCode == 200) {
+ status = response.statusCode;
+ if (status >= 200 && status < 300 || status == 304) {
response.body.push(chunk);
} else {
response.error = true;
- console.error('Image was not loaded. Status: %s [%s]', response.statusCode, uri);
+ console.error('Image was not loaded. Status: %s [%s]', status, uri);
}
});
View
2  package.json
@@ -1,7 +1,7 @@
{
"name" : "durilka",
"description" : "Simple tool for making data URIs from images in CSS files",
- "version" : "0.0.3",
+ "version" : "0.0.4",
"author" : "Mikhail Korepanov <panyakor@gmail.com>",
"homepage": "http://github.com/panya/durilka",
"repository" : {
Please sign in to comment.
Something went wrong with that request. Please try again.