No way to set a Url's host to a Host
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 406
- PR merge metrics
- No merged PRs in 30d
Description
I have the following code, using ruma_identifiers::UserId:
let mut autodiscovery_base_url =
Url::parse("https://hostname.invalid").expect("Url::parse is broken?!");
autodiscovery_base_url.set_host(Some(user_id.hostname().to_string()));
It would be nice to be able to avoid round-tripping through a string here. (It'd be nice if there was a minimal const EMPTY_URL: Url (e.g. the equivalent of Url::parse("about:").unwrap()) so I didn't have to parse a placeholder URL at runtime, too.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating Url::set_host and the Host type used by rust-url, then review the existing URL mutation tests and API conventions. The change is complete when a Host can be passed without converting through a string; the proposed minimal const empty URL is a separate point to assess.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100