servo / servo/rust-url

Url::make_relative strips leading /

Open
#772 0 comments 1 reaction 0 assignees View on GitHub

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

This is an arguably less-critical version of https://github.com/servo/rust-url/issues/766.

Leading slashes are also incorrectly stripped. For example, I would expect this to print "/bar":

use url::Url;

fn main() {
    let base = Url::parse("https://foo.com/").unwrap();
    let url = base.join("https://foo.com//bar").unwrap();
    println!("{}", base.make_relative(&url).unwrap());
    // actually prints "bar"
}

As it is, base.join("bar") obviously gives https://foo.com/bar which is a different url to https://foo.com//bar per the URL Standard.

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 at the Url::make_relative entry point and reproduce the example from the issue, comparing the result for https://foo.com//bar with the URL Standard behavior. Done means the relative result preserves the leading slash and a regression test covers this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.