servo / servo/rust-url

Method to get port regardless of defaults

Open
#706 9 comments 6 reactions 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

At the moment, when using the port method on an URL that uses a known scheme with none or the default port, port will return None.
port_or_known_default will always return the default port for known scheme's unless a non-default port is set in the URL.

Currently there is no way to determine if the input string contained a port or not, for applications which do not want to support any default ports, regardless of scheme's, this is a current limitation.

I propose adding a method port_int (like host_str, bikeshedding is welcome) that returns whatever port is set in the URL string, regardless of defaults.

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 by examining the existing port and port_or_known_default methods and their tests. Add a method that reports whether a port was present in the input regardless of known-scheme defaults, then verify behavior for omitted, default, and non-default ports.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.