From 491f49570db620fc39c0cb36f32edeba4714d607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Fri, 8 Jul 2011 16:03:08 +0200 Subject: [PATCH] allow using relative paths --- lib/mbtiles.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/mbtiles.js b/lib/mbtiles.js index d667b1c..26761d8 100644 --- a/lib/mbtiles.js +++ b/lib/mbtiles.js @@ -35,6 +35,17 @@ function MBTiles(uri, callback) { if (typeof callback !== 'function') callback = noop; if (typeof uri === 'string') uri = url.parse(uri); + if (!uri.pathname) { + callback(new Error('Invalid URI ' + url.format(uri))); + return; + } + + if (uri.hostname === '.') { + delete uri.hostname; + delete uri.host; + uri.pathname = '.' + uri.pathname; + } + this.filename = uri.pathname; Step(function() { mbtiles._db = new sqlite3.cached.Database(mbtiles.filename, this);