Skip to content

Commit

Permalink
Work-around for url.parse changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mojodna committed Jul 6, 2015
1 parent b09eb37 commit a74871c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changes

## v0.8.0 - 6/6/15

* Version-specific workaround for joyent/node#25636 / nodejs/io.js#2113
(breaking change in `url.parse` behavior)

## v0.7.0 - 5/9/15

* Make retries optional (`options.retry`, defaulting to `false`)
Expand Down
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var http = require("http"),
util = require("util");

var request = require("request"),
retry = require("retry");
retry = require("retry"),
semver = require("semver");

var meta = require("./package.json"),
NAME = meta.name,
Expand Down Expand Up @@ -86,6 +87,15 @@ module.exports = function(tilelive, options) {
};

var HttpSource = function(uri, callback) {
if (semver.satisfies(process.version, ">=0.11.0")) {
// Node 0.12 changes the behavior of url.parse such that components are
// url-encoded
uri.hash = decodeURIComponent(uri.hash);
uri.pathname = decodeURIComponent(uri.pathname);
uri.path = decodeURIComponent(uri.path);
uri.href = decodeURIComponent(uri.href);
}

this.source = url.format(uri).replace(/(\{\w\})/g, function(x) {
return x.toLowerCase();
});
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"license": "MIT",
"dependencies": {
"request": "^2.34.0",
"retry": "^0.6.1"
"retry": "^0.6.1",
"semver": "^4.3.6"
},
"peerDependencies": {
"tilelive": "*",
Expand Down

0 comments on commit a74871c

Please sign in to comment.