Closed ktonon closed 5 years ago
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
Just stumbled upon this issue
The slash is required though. This is what I tested:
> import UrlParser exposing(..)
> location = { href = "", host = "", hostname = "", protocol = "", origin = "", port_ = "", pathname = "",
> parsePath (s "aaa" </> string) { location | pathname = "/aaa/bbb" }
Just "bbb" : Maybe.Maybe String
> parsePath (s "aaa" </> string) { location | pathname = "/aaa/" }
Just "" : Maybe.Maybe String
> parsePath (s "aaa" </> string) { location | pathname = "/aaa" }
Nothing : Maybe.Maybe String
Stumbled on this, too. @crypticmind do you have a PR?
@sethlivingston I created #53, but @ktonon also created #43. Either of them will fix the issue. In the meantime, just use your own string parser in your routes:
string : Parser (String -> a) a
string =
custom "STRING" <|
\segment ->
if String.isEmpty segment then
Err "Empty string"
else
Ok segment
In my code, I'm actually validating the string isn't also blanks:
string : Parser (String -> a) a
string =
custom "STRING" <|
\segment ->
if segment |> String.trim |> String.isEmpty then
Err "Empty or blank string"
else
Ok segment
I'm closing this issue as this project is no longer active.
Doc for function
(</>)
shows:But
parsePath (s "search" </> string) location
returnsJust ""
because the implementation ofstring
isNot sure which is correct. Assuming the docs are the desired behaviour:
Using
elm-doc-test
would catch this earlier.Caught the issue while working on a PR to add doc tests. Using elm 0.18.0