Re: [whatwg/url] feat: handle Windows file paths with backslashes in URL parsing (PR #874)

@annevk commented on this pull request.

This looks surprisingly straightforward. Have you perhaps implemented this in jsdom as well to see what tests would need adjusting? @domenic would you care to have a look?

cc @jasnell @achristensen07 @anonrig 

> +       <li><p>Prepend "<code>///</code>" to <a>remaining</a>.
+       <li><p>Set <var>state</var> to <a>file state</a>.

Is there a difference between this and immediately jumping to the path state?

> @@ -2247,6 +2247,18 @@ and then runs these steps:
      <li><p>If <a>c</a> is an <a>ASCII alphanumeric</a>, U+002B (+), U+002D (-), or U+002E (.),
      append <a>c</a>, <a lt="ASCII lowercase">lowercased</a>, to <var>buffer</var>.
 
+     <li>
+      <p>Otherwise, if <a>c</a> is U+003A (:) and <var>buffer</var>'s <a for=string>length</a> is 1 and 
+      <var>buffer</var> contains only an <a>ASCII alpha</a> and <a>remaining</a> starts with U+005C (\), then:
+
+      <ol>
+       <li><p>Set <var>url</var>'s <a for=url>scheme</a> to "<code>file</code>".
+       <li><p>Set <var>buffer</var> to the empty string.
+       <li><p>Replace every U+005C (\) code point in <a>remaining</a> with U+002F (/).

Why is this needed?

> +      <p>Otherwise, if <a>c</a> is U+003A (:) and <var>buffer</var>'s <a for=string>length</a> is 1 and 
+      <var>buffer</var> contains only an <a>ASCII alpha</a> and <a>remaining</a> starts with U+005C (\), then:

```suggestion
      <p>Otherwise, if <a>c</a> is U+003A (:), <var>buffer</var>'s <a for=string>length</a> is 1, 
      <var>buffer</var> contains only an <a>ASCII alpha</a>, and <a>remaining</a> starts with
      U+005C (\):
```

> @@ -2247,6 +2247,18 @@ and then runs these steps:
      <li><p>If <a>c</a> is an <a>ASCII alphanumeric</a>, U+002B (+), U+002D (-), or U+002E (.),
      append <a>c</a>, <a lt="ASCII lowercase">lowercased</a>, to <var>buffer</var>.
 
+     <li>
+      <p>Otherwise, if <a>c</a> is U+003A (:) and <var>buffer</var>'s <a for=string>length</a> is 1 and 
+      <var>buffer</var> contains only an <a>ASCII alpha</a> and <a>remaining</a> starts with U+005C (\), then:
+
+      <ol>
+       <li><p>Set <var>url</var>'s <a for=url>scheme</a> to "<code>file</code>".

A newline after each `<li>` except the last one.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/pull/874#pullrequestreview-3021165802
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/pull/874/review/3021165802@github.com>

Received on Tuesday, 15 July 2025 16:26:58 UTC