Skip to content

Potentially inconsistent behavior with how URIs with wildcard subdomains and ports are handled #44

Open
@JessRudder

Description

I've noticed what appears to be inconsistent behavior with URI(my_uri). I tried reading the RFCs that URI is based on to understand if this was by design (but I couldn't parse the RFC all that well).

If I run URI("*.example.com:5555") I get the following error:

URI::InvalidURIError: bad URI(is not URI?): "*.example.com:5555"
from /Users/jessrudder/.rbenv/versions/3.1.2/lib/ruby/3.1.0/uri/rfc3986_parser.rb:67:in `split'

If I keep the wildcard and the port but add a scheme, I get the behavior I expected URI("http://*.example.com:5555")

scheme: "http"
userinfo: nil
host: "*.example.com"
port: 5555
path: ""

If I don't have the wildcard domain or a scheme, it appears to work but not all methods respond as expected URI("subdomain.example.com:5555")

scheme: "subdomain.example.com"
user_info: nil
host: nil
port: nil
path: nil

If I remove the port and don't have a scheme, it appears to work but not all methods respond as expected URI("*.example.com")

scheme: nil
userinfo: nil
host: nil
port: nil
path: "*.example.com"

I'd be happy to try to work on a PR but wanted to confirm that this behavior was incorrect before I did that. Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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