URI parser cannot parse URNs
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 378
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Description
It seems the URI parser stumbles with URNs. A simple test to reproduce:
fn main() {
use http::uri::Uri;
let uri = "urn:isbn:1238492".parse::<Uri>();
println!("{:?}", uri);
}
Produces the output:
$ ./testcase
Err(InvalidUri(InvalidAuthority))
The authority is only present when the scheme is followed by //, otherwise the parser should be parsing everything after the first : as the path. Python gets this right, and Go parses this as Opaque (instead of Host, but still successfully parses):
Python:
>>> urlparse('urn:isbn:0451450523')
ParseResult(scheme='urn', netloc='', path='isbn:0451450523', params='', query='', fragment='')
Go:
>>> url, _ := url.Parse("urn:isbn:0451450523")
>>> fmt.Println("Host (Opaque):", url.Opaque)
Host (Opaque): isbn:0451450523
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 with the Rust http::uri::Uri parsing entry point and reproduce the provided urn:isbn:1238492 example. Compare the parser's behavior with the stated URI rule and the Python and Go results. Done means a URN parses successfully and the text after the first colon is handled as path or opaque content rather than an invalid authority.
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