pub fn normalize_sqlite_url(database_url: &str) -> StringExpand description
Rewrites a sqlite: URL so sqlx::any::AnyConnectOptions::from_str’s
strict RFC 3986 parsing (via the url crate) resolves it the same way
the old, lenient, SQLite-specific SqliteConnectOptions::from_str this
crate used before adding MySQL support always did - see connect’s
own doc comment for the full explanation of why this is needed at
all (in short: a Windows absolute path’s C: drive letter, sitting
right after sqlite://, gets misread as a host:port-shaped URL
authority component otherwise).
Two independent fixes, both SQLite-only:
- Backslash path separators become forward slashes (accepted by every SQLite/Windows filesystem API too, and never ambiguous with anything URL syntax uses).
- A path that looks like a Windows drive-absolute path (
C:/...) gets an explicit empty authority inserted (sqlite:///C:/..., three slashes) - the standard “no host, absolute path” URL convention (file:///...follows the identical shape). A relative path (sqlite://database/database.sqlite, this codebase’s own scaffold default) is deliberately left as a two-slash URL: forcing a leading/onto it would silently turn it into a path rooted at the filesystem root, a real behavior change, not a parsing fix.