Re: [whatwg/url] Can a URL have a segmented path with zero segments? (Issue #926)

Scripter17 left a comment (whatwg/url#926)

> I'm not sure where you are seeing "path start with /" checks. You'd have to serialize the path first to be able to do that.

The [URL crate](https://docs.rs/url/latest/url/struct.Url.html#method.path_segments) for Rust has a Url::path_segments method that returns None for `non-special://example.com` but states that it only returns None for cannot-be-a-base URLs. I admit that crate is a bit spotty on spec compliance but my URL crate has the same behavior there and passes all the parser and setter tests.

> I'm also fairly certain this is tested by WPT. What cases are not covered in your experience?

Maybe I'm missing something but if there were tests saying "the URL `https://example.com/a/b/c` has path segments `a`, `b`, and `c`" I'd expect them to be somewhere in https://github.com/web-platform-tests/wpt/tree/master/url/resources or maybe its parent directory but it seems to only say that the URL has a path of `/a/b/c`. Fitting them into the existing urltestdata.json would require the URL API expose a concept of path segments to users so I get why it'd be in a separate file but I don't understand why it'd be in a different folder.

If nothing else, could you confirm which interpretation is correct so I can fix my code if needed? I'm having difficulty reading the spec any other way but I have difficulty reading the spec at all.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/926#issuecomment-4955660425
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/926/4955660425@github.com>

Received on Monday, 13 July 2026 07:51:10 UTC