hyperium / hyperium/http

`Uri::path()` and and `Uri::path_and_query()` have confusing semantics

Open
#176 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-uri B-rfc
Dominant language
Rust
Stars
1.4k
Forks
378
Avg merge
1d 21h
Merged PRs (30d)
5

Description

path() returns &str which means it is never missing. Then why does path_and_query() return Option<&str> instead of &str? In other words, if the path is never missing then how can path_and_query() ever be missing? Under what circumstances would path_and_query() return None?

path() returns * when the URI is *. This seems really error prone. Regardless, what does path_and_query() return when path() returns *? This should be documented.

I would expect that url.path_and_query().unwrap().starts_with(url.path()) never panics and is always true, and that url.path_and_query().unwrap() == url.path() + url.query().map(|q| "?" + q) never panics and is always true. That is, I would expect that url.path_and_query() never returns None.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Uri::path(), Uri::path_and_query(), and Uri::query() entry points, focusing on ordinary URIs and the * URI. Document when path_and_query() can return None and what it returns for *, making the documented relationships between these methods explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.