Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Grammar matches against non-URI strings #4

bbkr opened this Issue · 3 comments

2 participants


IRC log

14:03 bbkr: star: use IETF::RFC_Grammar::URI; say so " " ~~  m/<IETF::RFC_Grammar::URI::TOP>/
14:03 p6eval: star 2012.05: OUTPUT«True␤»
14:04 jnthn: ...that doens't look like a URI to me :)
14:04 bbkr: indeed, creating GH issue now...
14:09 moritz: ah, and the space is never parsed, because the regex is not anchored

RFC 3986, Uniform Resource Identifier (URI): Generic Syntax, has a section (4.2) on the "Relative Reference" which makes the empty string a valid relative reference, or URI of sorts, relative to a base URI. So relative to both the empty string and '/foo.html' are valid relative references. I have chosen to make a relative reference a valid thing to parse as an URI. In response to this situation w3 (see has identified the concept of "a valid non-empty URL".

As discussed on IRC yesterday,, the URI module has a validating URI rule which somewhat addresses the initial complaint of treating " " as an URI. If you don't need relative references there is also a URI rule which should match and

You raised an objection that sometimes you are searching for URIs and matching the empty string doesn't really make sense. In response I propose to add a "valid non-empty URL(/URI)" rule which can be used for such searches.



Since there was no other comment on this matter I added a grammar rule TOP_non_empty to partially remedy bbkr's complaint. It seems to me that it is reasonable to add a search method to the URI module, which would also make it easy to add some tests. Note that this functionality goes beyond Perl 5 URI AFAIK. The additional step is a bit involved since I think it would also make sense for the search method to be lazy and fixing that may wait for another day. So some progress on this issue but leaving it open for now.


Resolution of this now depends on an open rakudo ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.