diff --git a/lib/get.js b/lib/get.js
index bb26b38..b1ad607 100644
--- a/lib/get.js
+++ b/lib/get.js
@@ -65,7 +65,7 @@ module.exports = function get(url, options) {
debug('request %s', url, settings);
cache[url] = new Promise(function (resolve, reject) {
- request(url, settings, function response(error, res, body) {
+ request(encodeURI(url), settings, function response(error, res, body) {
if (error) {
debug('request failed: %s', error.message);
return reject(error);
diff --git a/test/fixtures/Hólsgerðislaug-300x225.gif b/test/fixtures/Hólsgerðislaug-300x225.gif
new file mode 100644
index 0000000..472727f
Binary files /dev/null and b/test/fixtures/Hólsgerðislaug-300x225.gif differ
diff --git a/test/fixtures/image-inline-special-chars.result.html b/test/fixtures/image-inline-special-chars.result.html
new file mode 100644
index 0000000..009409c
--- /dev/null
+++ b/test/fixtures/image-inline-special-chars.result.html
@@ -0,0 +1 @@
+
inline image with special characters
diff --git a/test/fixtures/image-inline-special-chars.src.html b/test/fixtures/image-inline-special-chars.src.html
new file mode 100644
index 0000000..4c778a6
--- /dev/null
+++ b/test/fixtures/image-inline-special-chars.src.html
@@ -0,0 +1,10 @@
+
+
+
+
+ inline image with special characters
+
+
+
+
+
diff --git a/test/index.test.js b/test/index.test.js
index f6fe7f6..3e70c0a 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -8,9 +8,17 @@ var st = require('st');
var server;
test('setup mock server', function (t) {
- server = http.createServer(
- st(path.resolve(__dirname, 'fixtures'))
- ).listen(54321);
+ server = http.createServer(function(req, res) {
+ if (isASCII(req.url)) {
+ st(path.resolve(__dirname, 'fixtures'))(req, res);
+ }
+ else {
+ // Fail because all non-ascii chars should be urlencoded
+ // (some http servers don't handle non-ascii)
+ res.statusCode = 404;
+ res.end();
+ }
+ }).listen(54321);
server.on('listening', function listening() {
t.pass('mock server ready');
@@ -120,3 +128,7 @@ test('tear down', function (t) {
t.pass('tear down complete');
t.end();
});
+
+function isASCII(str) {
+ return /^[\x00-\x7F]*$/.test(str);
+}