Skip to content

Commit d20a0b3

Browse files
davidsmfreireclaude
andcommitted
fix(introspect): treat Windows drive letters as bare paths, not URL schemes
`C:\path\to\db.sqlite` parses as a URL with scheme `c`, which routed the input to the UnsupportedScheme branch and broke the SQLite roundtrip test on the Windows CI runner. A single-letter "scheme" is almost always a Windows drive letter, so short-circuit URL parsing for that case and let the input fall through as a filesystem path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8d49f7a commit d20a0b3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • sqlshield-introspect/src

sqlshield-introspect/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ pub fn introspect(db_url: &str) -> Result<TablesAndColumns, IntrospectError> {
5454
}
5555

5656
fn url_scheme(s: &str) -> Option<String> {
57+
// Windows drive letters (`C:\…`) parse as a single-character URL
58+
// scheme, which would otherwise route a bare path through the
59+
// unsupported-scheme branch. Treat any single-letter "scheme" as a
60+
// bare filesystem path.
61+
let bytes = s.as_bytes();
62+
if bytes.len() >= 2 && bytes[1] == b':' && bytes[0].is_ascii_alphabetic() {
63+
return None;
64+
}
5765
url::Url::parse(s)
5866
.ok()
5967
.map(|u| u.scheme().to_ascii_lowercase())
@@ -170,4 +178,12 @@ mod tests {
170178
assert!(tables["users"].contains("name"));
171179
assert!(tables["orders"].contains("user_id"));
172180
}
181+
182+
#[test]
183+
fn windows_drive_letter_is_not_treated_as_url_scheme() {
184+
assert_eq!(url_scheme("C:\\foo\\bar.db"), None);
185+
assert_eq!(url_scheme("d:/relative.sqlite"), None);
186+
assert_eq!(url_scheme("postgres://x/y").as_deref(), Some("postgres"));
187+
assert_eq!(url_scheme("/abs/path.db"), None);
188+
}
173189
}

0 commit comments

Comments
 (0)