Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register_scheme does not comply with rfc2396 (or 3986) #89

Open
doriantaylor opened this issue Sep 12, 2023 · 2 comments
Open

register_scheme does not comply with rfc2396 (or 3986) #89

doriantaylor opened this issue Sep 12, 2023 · 2 comments

Comments

@doriantaylor
Copy link

doriantaylor commented Sep 12, 2023

RFC2396 § 3.1 states that the grammar for a URI scheme is:

      scheme        = alpha *( alpha | digit | "+" | "-" | "." )

whereas .register_scheme uses const_set and the grammar of Ruby constants is inconsistent with the grammar for a URI scheme:

  def self.register_scheme(scheme, klass)
    Schemes.const_set(scheme.to_s.upcase, klass)
  end

How much trouble would it be to switch to a Hash keyed by Symbols, so that it's possible to register (compliant) URI schemes with hyphens, + signs, dots?

@duerst
Copy link
Member

duerst commented Sep 12, 2023

How many schemes are there that actually use a '.'?

@doriantaylor
Copy link
Author

The answer is fourteen:

$ curl -s https://www.iana.org/assignments/uri-schemes/uri-schemes.txt | sed -n '/^\([a-z][^ ]*\)/ s/\([^[:space:]]*\).*/\1/ p' | grep '\.' | wc -l
$ 14

…along with five that contain a + and 81 that contain a -.

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

No branches or pull requests

2 participants