Some special URI input

Hello,
i’m not sure, if a URI like http://.... or http://. is entered, should the parser return null or a Uri instance?
if the parser should return a Uri instance, "." should belong to host, path or query?
Because "." belong to pchar:
pchar = unreserved / pct - encoded
unreserved = ALPHA / DIGIT / "."

You can take a look at the grammar:

  • It can not be in the query because there is no delimiter ?
  • It can not be in the path because there is no path char /
  • It is a valid `reg-name and therefore a valid host.

You can now write down the derivation to see what part belongs where.

1 Like

Hello,
I still have a small problem, for example UriParserFactory.create("scheme://256.230.300.256").parse(), this should return null right? because 300 and 256 are out of range and not in dec-octet. But the feedback that dailytest gave me was AssertionError: expected null, but was:<prog2.uri.ref.UriRef@6ee27532> (I used assertNull() to judge).

Or entering scheme://256.230.300.256 should return a Uri instance, my understanding is wrong.

If you look at the grammar, you see that host can be a reg-name which are pchar which can be unreserved which can be digits and dots.
Try to draw a derivation tree and see what rules apply.

1 Like