purescript-contrib/purescript-routing

Parsing "/"

Opened this issue · 3 comments

bigs commented

hey all,

i've noticed a little oddity when writing my route parser... i've gotten into the practice of using end to explicitly terminate my routes (probably wroth adding notes to this effect in the docs (happy to help). anywho, end proves to be essential in stopping a "root" route parser (i.e. /) from matching everything. in order to get it to properly match, however, i had to write a parser like so:

lit "" *> lit "" *> end

which i found to be particularly odd, since i don't need it in routes that are further populated, i.e.

lit "" *> lit "foo" *> end

will properly match /foo

is this expected behavior? if not, is this something we should look at?

Should there be a difference between /foo and /foo/?

lit "" *> lit "foo" *> end = /foo
lit "" *> lit "foo" *> lit "" *> end = /foo/

I think lit "" *> lit "" *> end makes sense given that there's a difference between "" and "/", but I think we should export an alias for it.

Maybe the issue is that "" tokenizes as [ "" ] rather than [ ]?