Skip to content

Conversation

@tianzhou
Copy link
Contributor

Fix #137

Copilot AI review requested due to automatic review settings November 24, 2025 10:33
Copilot finished reviewing on behalf of tianzhou November 24, 2025 10:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Windows absolute path handling in SQLite DSN parsing (issue #137). The URL parser was incorrectly handling Windows drive letters like C:/, which resulted in invalid paths. The fix adds pattern matching to detect and correctly parse Windows-style absolute paths.

Key changes:

  • Added regex-based detection for Windows drive letter paths (`/^/[A-Za-z]://)
  • Updated documentation with the correct Windows path format
  • Added comprehensive test coverage for path parsing scenarios including Windows, Unix, relative paths, and in-memory databases

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/connectors/sqlite/index.ts Added Windows drive letter path detection and handling logic
src/connectors/tests/sqlite.integration.test.ts Added comprehensive DSN path parsing test suite covering Windows, Unix, relative paths, and in-memory databases
docs/config/server-options.mdx Corrected Windows path example to use proper DSN format with three slashes

Comment on lines +61 to +62
} else if (url.pathname.match(/^\/[A-Za-z]:\//)) {
// Windows absolute path: sqlite:///C:/path/to/db.sqlite
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern only matches forward slashes after the drive letter, but Windows paths can use backslashes. The pattern should be /^\/[A-Za-z]:[\/\\]/ to handle both C:/ and C:\ formats. Although the URL parser typically normalizes to forward slashes, this would make the code more robust.

Suggested change
} else if (url.pathname.match(/^\/[A-Za-z]:\//)) {
// Windows absolute path: sqlite:///C:/path/to/db.sqlite
} else if (url.pathname.match(/^\/[A-Za-z]:[\/\\]/)) {
// Windows absolute path: sqlite:///C:/path/to/db.sqlite or sqlite:///C:\path\to\db.sqlite

Copilot uses AI. Check for mistakes.
Comment on lines 58 to +61
if (url.pathname.startsWith("//")) {
// Absolute path: sqlite:///path/to/db.sqlite
// Unix absolute path: sqlite:///path/to/db.sqlite
dbPath = url.pathname.substring(2); // Remove leading //
} else if (url.pathname.match(/^\/[A-Za-z]:\//)) {
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition order creates a logic error: Windows UNC paths like //server/share would incorrectly match the Unix absolute path check first. The Windows drive letter check should come before the // check, or add an additional condition to exclude Windows drive patterns from the Unix path logic (e.g., url.pathname.startsWith('//') && !url.pathname.match(/^\/\/[A-Za-z]:\//)).

Copilot uses AI. Check for mistakes.
@tianzhou tianzhou merged commit fe86247 into main Nov 24, 2025
8 checks passed
@tianzhou tianzhou deleted the windows_absolute_path branch November 26, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite absolute path on Windows cannot be loaded correctly

2 participants