Skip to content

URI: how to distinguish from invalid port vs no port number  #509

@niklasad1

Description

@niklasad1

Hey,

I read that default port was rejected in #11.

However, the current API has pub fn port(&self) -> Option<Port<&str>> but it's not possible to
distinguish when invalid port number vs when no port number.
.
Example:

let uri: Uri = "/hello/world".parse().unwrap();
assert!(uri.port().is_none());

let uri: Uri = "/hello/world:-9933".parse().unwrap();
assert!(uri.port().is_none());

Opinions about having pub fn port(&self) -> Result<Option<Port<&str>, Error> or something similar?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions