Re: [whatwg/url] Add URL path equality and prefix comparison (PR #929)

@rmisev commented on this pull request.



> @@ -1950,7 +1950,7 @@ the <a>blob URL store</a> between parsing and fetching, while fetching will stil
 or more <a>URL path segments</a>.
 
 <p>A <dfn export>URL path segment</dfn> is an <a for=/>ASCII string</a>. It commonly refers to a
-directory or a file, but has no predefined meaning.
+directory or a file, but has no predefined meaning. It never contains U+002F (/).

This is not always true for opaque paths. For example, the path of the URL `about:a/b` is the segment `a/b`.

> +these steps. They return a boolean.
+
+<ol>
+ <li><p>If <var>A</var> is a <a for=/>URL path segment</a> or <var>B</var> is a
+ <a for=/>URL path segment</a>, then return false.
+
+ <li><p>If <var>B</var>'s <a for=list>size</a> is greater than <var>A</var>'s
+ <a for=list>size</a>, then return false.
+
+ <li><p><a for=list>For each</a> <var>index</var> of <var>B</var>'s <a for=list>indices</a>: if
+ <var>A</var>[<var>index</var>] is not <var>B</var>[<var>index</var>], then return false.
+
+ <li><p>Return true.
+</ol>
+
+<p class=note>As <a for=/>URL path segments</a> never contain U+002F (/), this can only be true when

> *As [URL path segments](https://whatpr.org/url/929.html#url-path-segment) never contain U+002F (/),*

See my first comment.

> +<p class=note>Comparing <a for=/>URL path segments</a> rather than serializations matters for
+<a for=/>URL paths</a> that were not produced by the <a>URL parser</a>: the serialization of an
+<a for=url>opaque path</a> can be identical to that of a <a for=/>list</a> of
+<a for=/>URL path segments</a>.

This may also apply to URL paths produced by the URL parser when serialized paths are empty. For example, the paths of the following URLs are not equal: .
URL | path
-|-
`non-spec:` | empty string
`non-spec://h` | empty list

So maybe some examples can be added here?

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

Message ID: <whatwg/url/pull/929/review/5094899596@github.com>

Received on Thursday, 3 September 2026 17:35:37 UTC