raku-community-modules / URI

Raku realization of URI — Uniform Resource Identifiers handler
Artistic License 2.0
3 stars 14 forks source link

URI with missing components parses with uninitialized value warning #42

Closed zostay closed 1 year ago

zostay commented 5 years ago

The proof of concept of this is just to run either of these

URI.new(uri => '');
URI.new(uri => 'http:');

The output received is:

Use of uninitialized value of type Any in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful.
  in block  at /Users/sterling/Documents/code/perl6/URI/lib/URI.pm (URI) line 67

Whatever the correct behavior ought to be for these URI's, throwing out an uninit warning is not right.

JJ commented 5 years ago

I guess we'll have to take a look at this now...

JJ commented 1 year ago

Now it does not error, it simply passes:

URI.new(query-form-delimiter => Str, grammar => IETF::RFC_Grammar.new(rfc => "rfc3986", grammar => IETF::RFC_Grammar::URI, parse-result => Match.new(:orig(""), :from(0), :pos(0), :hash(Map.new((:URI-reference(Match.new(:orig(""), :from(0), :pos(0), :hash(Map.new((:relative-ref(Match.new(:orig(""), :from(0), :pos(0), :hash(Map.new((:relative-part(Match.new(:orig(""), :from(0), :pos(0), :hash(Map.new((:path-empty(Match.new(:orig(""), :from(0), :pos(0))))))))))))))))))))))), match-prefix => Bool::False, path => URI::Path.new(path => "", segments => ("",)), scheme => "", authority => URI::Authority, query => URI::Query.new(hash-format => HashFormat::Lists), fragment => "")

Empty URIs are correct?

JJ commented 1 year ago

Ditto for the second one:

URI.new(query-form-delimiter => Str, grammar => IETF::RFC_Grammar.new(rfc => "rfc3986", grammar => IETF::RFC_Grammar::URI, parse-result => Match.new(:orig("http:"), :from(0), :pos(5), :hash(Map.new((:URI-reference(Match.new(:orig("http:"), :from(0), :pos(5), :hash(Map.new((:URI(Match.new(:orig("http:"), :from(0), :pos(5), :hash(Map.new((:hier-part(Match.new(:orig("http:"), :from(5), :pos(5), :hash(Map.new((:path-empty(Match.new(:orig("http:"), :from(5), :pos(5)))))))),:scheme(Match.new(:orig("http:"), :from(0), :pos(4)))))))))))))))))), match-prefix => Bool::False, path => URI::Path.new(path => "", segments => ("",)), scheme => "http", authority => URI::Authority, query => URI::Query.new(hash-format => HashFormat::Lists), fragment => "")
JJ commented 1 year ago

Which is apparently the right behavior