optional/default are not wokring with segment
Closed this issue · 3 comments
Hi,
It seems segment
never fails and return empty string in case of failure.
optional
and default
break because of this.
Can you post a try.purescript.org reproduction? I believe you have misdiagnosed your issue. segment
is Parser.take
, which does not operate the way you are describing.
purescript-routing-duplex/src/Routing/Duplex/Parser.purs
Lines 207 to 211 in 13702d4
Yep the issue happens not always, but only when segment is empty.
So default "expect" segment
works for parsing empty string but not "/"
If route is a complex object it contains multiple segments.
So following paths "/////" "/" "////" produce different Routes.
That is expected. Internally we do not normalize paths, as this is no longer bidirectional from the source input. If you have a leading /
, then that's what the root
combinator is for. You can choose to implement normalization yourself (you may not care about strict bidirectionality) by constructing your own pass on top of parsePath
.