Inconsistency for "dbname" with relative filenames
Grinnz opened this issue · 2 comments
Grinnz commented
There seems to be a bit of an inconsistency between a SQLite URI with a host specified and one with an empty authority, if the "dbname" section does not start with a /
. I'm not sure how best to explain it so here are some examples.
$ perl -MURI::db -E'say URI->new("db:sqlite:///foo.db")->dbname'
/foo.db
$ perl -MURI::db -E'say URI->new("db:sqlite://localhost/foo.db")->dbname'
foo.db
$ perl -MURI::db -E'say URI->new("db:sqlite:////foo.db")->dbname'
/foo.db
$ perl -MURI::db -E'say URI->new("db:sqlite://localhost//foo.db")->dbname'
/foo.db
$ perl -MURI::db -E'my $uri = URI::db->new("sqlite://"); $uri->dbname("foo.db"); say $uri'
db:sqlite:///foo.db
The last example is an odd case where setting dbname results in getting a different dbname back, because sqlite:///foo is interpreted as an absolute file path.
theory commented
I think that fixes the issue, @Grinnz. It's a bit funky parsing the URI to figure this stuff out.
Grinnz commented
Looks good to me, thanks!