Skip to content

Commit 5114a7f

Browse files
committed
fix: support passing file:// URI when SQLite was compiled with SQLITE_USE_URI=1
I'm trying to use `better-sqlite3` with an SQLite that is compiled with `SQLITE_USE_URI=1`: ```js const db = SQLite(`file:///foo/bar?vfs=myfs&mode=ro&immutable=1`); ``` This, however, doesn't work right now, since there's an erroneous assertion in the database creation. With this patch, I can successfully connect to database. References WiseLibs#483
1 parent 6108911 commit 5114a7f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/database.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function Database(filenameGiven, options) {
6161
}
6262

6363
// Make sure the specified directory exists
64-
if (!anonymous && !fs.existsSync(path.dirname(filename))) {
64+
if (!filename.startsWith('file://') && !anonymous && !fs.existsSync(path.dirname(filename))) {
6565
throw new TypeError('Cannot open database because the directory does not exist');
6666
}
6767

0 commit comments

Comments
 (0)