Skip to content

Option to keep default port #132

Open
@lutovich

Description

@lutovich

Currently parsed URL does not contain port when its value is the default for the specified protocol:

parse("http://localhost:80").port === ''
parse("https://localhost:443").port === ''

It would be great to have an option/parameter to keep the port number even if it is the default for the protocol.

This would be useful when default port is defined by the environment/application requirements and is different from the standard. For example, an application might want to interpret http://localhost as http://localhost:8080 and not http://localhost:80. Only http://localhost:80 will be interpreted as http://localhost:80. Right now after URL has been parsed there is no way to know if port was not specified or default port was specified.

I'd be glad to provide a PR for this. Not sure if it fine to just add a 4th parameter to the URL function.

P.S. thanks for this library, it is really convenient and simple to use!

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