Url::make_relative unconditionally strips trailing `/`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 406
- PR merge metrics
- No merged PRs in 30d
Description
- Note that this crate implements the URL Standard not RFC 1738 or RFC 3986
join and make_relative are presented as inverse functions. However, make_relative strips the trailing / when asked to make a directory relative to some base. For example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=5da4403820faf5f73ad79ac9c2e4ef1c
This is rather unexpected since join makes a point to remind the user how significant trailing / are since they indicate the url refers to a directory. Essentially, you cannot:
let base = Url::parse("file:///base/")?;
let url = base.join("directory/")?;
let directory = base.make_relative(&url)?; // yields "directory" sans `/`
I ran into because I'm actually trying to construct a relative directory url given an absolute file url and cannot seem to figure out a way to do so without manually checking for a trailing / and adding it back.
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
The affected entry point is Url::make_relative; compare its result with Url::join using the file:///base/ and directory/ example. Trace how trailing slashes are handled, then verify that making the joined directory URL relative preserves the slash and keeps the two operations consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100