test: add more test cases for pathToFileURL#63293
Conversation
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
4069b78 to
875c813
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63293 +/- ##
==========================================
+ Coverage 90.05% 90.30% +0.24%
==========================================
Files 714 730 +16
Lines 225247 234773 +9526
Branches 42578 43955 +1377
==========================================
+ Hits 202842 212001 +9159
- Misses 14181 14485 +304
- Partials 8224 8287 +63 🚀 New features to boost your workflow:
|
| const forbiddenHostnameChars = [ | ||
| '\\\\exa mple\\share\\file.txt', | ||
| '\\\\host name\\share\\file.txt', // space | ||
| '\\\\host#name\\share\\file.txt', // hash | ||
| '\\\\host?name\\share\\file.txt', // question mark | ||
| '\\\\host@name\\share\\file.txt', // at sign | ||
| '\\\\host:name\\share\\file.txt', // colon | ||
| '\\\\host/name\\share\\file.txt', // forward slash | ||
| '\\\\host[name\\share\\file.txt', // left bracket | ||
| '\\\\host]name\\share\\file.txt', // right bracket | ||
| ]; |
There was a problem hiding this comment.
According to https://url.spec.whatwg.org/#host-miscellaneous, there are a few more forbidden char we might as well check for:
| const forbiddenHostnameChars = [ | |
| '\\\\exa mple\\share\\file.txt', | |
| '\\\\host name\\share\\file.txt', // space | |
| '\\\\host#name\\share\\file.txt', // hash | |
| '\\\\host?name\\share\\file.txt', // question mark | |
| '\\\\host@name\\share\\file.txt', // at sign | |
| '\\\\host:name\\share\\file.txt', // colon | |
| '\\\\host/name\\share\\file.txt', // forward slash | |
| '\\\\host[name\\share\\file.txt', // left bracket | |
| '\\\\host]name\\share\\file.txt', // right bracket | |
| ]; | |
| const forbiddenHostnameChars = Array.from('\0\t\n\r #:<>?@[]^|', (sep) => `\\\\host${sep}name\\share\\file.txt`); |
But it looks like \n, \r, \t are ignored instead of being rejected; # and ? might have a special significant in UNC not sure
There was a problem hiding this comment.
I've opened ada-url/ada#1142 to address the # and ? cases
There was a problem hiding this comment.
Ok, I will wait it to reach Node.js main, ping me please
There was a problem hiding this comment.
Sorry forgot to follow up, but the upstream issue was closed so let's limit to the ones that are supported
| const forbiddenHostnameChars = [ | |
| '\\\\exa mple\\share\\file.txt', | |
| '\\\\host name\\share\\file.txt', // space | |
| '\\\\host#name\\share\\file.txt', // hash | |
| '\\\\host?name\\share\\file.txt', // question mark | |
| '\\\\host@name\\share\\file.txt', // at sign | |
| '\\\\host:name\\share\\file.txt', // colon | |
| '\\\\host/name\\share\\file.txt', // forward slash | |
| '\\\\host[name\\share\\file.txt', // left bracket | |
| '\\\\host]name\\share\\file.txt', // right bracket | |
| ]; | |
| const forbiddenHostnameChars = Array.from('\0 :<>@[]^|', (sep) => `\\\\host${sep}name\\share\\file.txt`); |
There was a problem hiding this comment.
Yes, that's why I sent 51f1a25. Honestly, it's much clearer to see that list than the approach you suggested.
Just to make sure we won't introduce any regression anytime further (based on H1 reports we received).