-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
Description
parseHash parses query params from the main URL not from the hash part
For example this common use-case http://example.com/app/#items?filter=cats
It cannot be implemented using this module.
In my case parseLocation always returns Nothing if the hash query used.
urlToRoute : Parser (Route -> a) a
urlToRoute =
oneOf
[ map MainRoute top
, map ItemListRoute (s "items" <?> stringParam "filter")
, map ItemRoute (s "items" </> string)
, map AboutRoute (s "about")
]
parseLocation : Location -> Route
parseLocation location =
parseHash urlToRoute location
I expect the function with the name "parseHash" parses hash only, but instead, it parses the "location.search" as I can see here
https://github.com/evancz/url-parser/blob/master/src/UrlParser.elm#L353
The workaround I use is this (not very elegant, sorry)
fixLocationQuery : Location -> Location
fixLocationQuery location =
let
hash =
String.split "?" location.hash
|> List.head
|> Maybe.withDefault ""
search =
String.split "?" location.hash
|> List.drop 1
|> String.join "?"
|> String.append "?"
in
{ location | hash = hash, search = search }klazuka, amilner42, j-panasiuk, williamho, pdarden and 19 more