- From: Mert Can Altin <notifications@github.com>
- Date: Sat, 18 Oct 2025 09:04:36 -0700
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/pull/874/c3418614189@github.com>
mertcanaltin left a comment (whatwg/url#874)
Thank you for the clarification! I've simplified the implementation to follow your guidance exactly.
## What Changed
Now only **single ASCII letter + `:\`** is treated as a Windows file path. Everything else goes through normal URL parsing:
✅ `C:\path` → `file:///C:/path` (Windows path)
✅ `D:\file.txt` → `file:///D:/file.txt` (Windows path)
❌ `CC:\path` → Normal URL parsing (scheme: `cc`)
❌ `ABC:\path` → Normal URL parsing (scheme: `abc`)
❌ `1:\path` → Normal URL parsing
❌ `\\server\share` → Normal URL parsing (no special UNC handling)
❌ `a:/foo` → Normal URL parsing (forward slash is NOT a Windows path)
## Implementation
The code is now much simpler - just 7 lines instead of 36:
```javascript
// Only convert single ASCII letter + :\ pattern (e.g., C:\, D:\)
// Note: Only backslash (\), not forward slash (/)
if (!stateOverride && !this.url.scheme && /^[a-zA-Z]:\\/u.test(this.input)) {
const converted = this.input.replace(/\\/gu, "/");
this.input = `file:///${converted}`;
}
```
## Test Results
The simplified approach dramatically improved test results:
- **Before**: 5342/5381 passing (99.3%), 38 failures
- **After**: 5325/5331 passing (**99.9%**), only 5 failures
- The 5 remaining failures are IDNA tests (Unicode domain encoding), completely unrelated to Windows path handling
## Next Steps
I need to update the WPT tests to reflect that `CC:\`, `ABC:\`, etc. should go through normal URL parsing instead of failing. Should these patterns:
1. Be treated as normal schemes (e.g., `CC:\path` → scheme: `cc`, path: `\path`)?
2. Or should they fail during normal URL parsing due to the backslash?
Let me know and I'll update the test expectations accordingly!
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/pull/874#issuecomment-3418614189
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/url/pull/874/c3418614189@github.com>
Received on Saturday, 18 October 2025 16:04:40 UTC