allow using relative paths

This commit is contained in:
Konstantin Käfer
2011-07-08 16:03:08 +02:00
parent c6dc413816
commit 491f49570d

View File

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