Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Hash-Routing (again) #24

Open
andys8 opened this Issue Nov 26, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@andys8
Copy link

andys8 commented Nov 26, 2018

Issue

evancz/url-parser had parseHash. It was removed.

In my case "Url-Routing" is not an option, because the http server is not under my control and will issue 404.

Parsing a url like http://localhost:3000/#/mydata/abe8e05f-e58a-4bfc-81e8-2081c7638407 is hacky. There is fragment. It returns Maybe String. There is no way to parse String with the library. Therefore the workaround shown is working, but not what anybody would want.

Are there alternatives without adding the functionality? If not, can we support hash routing again?

Workaround

parseUrl : Url -> Maybe Route
parseUrl url =
    UrlParser.parse parseRoute (urlFragmentToPath url)

urlFragmentToPath : Url -> Url
urlFragmentToPath url =
    { url | path = Maybe.withDefault "" url.fragment, fragment = Nothing }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.