Skip to content

Trying to parse a URL into a Route enum #179

Answered by stephencelis
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

@wtruppel That's a pretty bad error message 😞

The main issue is that PrefixUpTo (and most parsers on strings) will output a Substring, so to bundle things up into your enum you must first convert the value back to a string:

Query("token", PrefixUpTo("&").map(String.init))

Please note, though, that query parsers are already split up to work on individual items, so the "&" character shouldn't be relevant at this point. I think you could instead do:

Query("token", Rest().map(String.init))

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ghost
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant