From 9e0c85b03c3e103b58f03546872fe955f04373b4 Mon Sep 17 00:00:00 2001 From: Tom Lee Date: Wed, 12 Nov 2014 18:58:27 -0500 Subject: [PATCH] fix error when mbtiles path contains a space root cause is that qs.parse() unescapes URL components while url.parse() does not. https://groups.google.com/forum/#!topic/nodejs/8P7GZqBw0xg http://nodejs.org/api/querystring.html#querystring_querystring_unescape --- lib/mbtiles.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mbtiles.js b/lib/mbtiles.js index c7fc7e3..f8a50ee 100644 --- a/lib/mbtiles.js +++ b/lib/mbtiles.js @@ -31,8 +31,11 @@ MBTiles.schema = fs.readFileSync(__dirname + '/schema.sql', 'utf8'); // - callback: Will be called when the resources have been acquired // or acquisition failed. require('util').inherits(MBTiles, require('events').EventEmitter) -function MBTiles(uri, callback) { - if (typeof uri === 'string') uri = url.parse(uri, true); +function MBTiles(uri, callback) { + if (typeof uri === 'string') { + uri = url.parse(uri, true); + uri.pathname = qs.unescape(uri.pathname); + } else if (typeof uri.query === 'string') uri.query = qs.parse(uri.query); if (!uri.pathname) {