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
This commit is contained in:
Tom Lee
2014-11-12 18:58:27 -05:00
parent 12052a280d
commit 9e0c85b03c

View File

@@ -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) {