wking-io / elm-live

⚡ A flexible dev server for Elm. Live reload included.
https://elm-live.com
MIT License
1.05k stars 61 forks source link

elm-live assumes any URL ending in .com is a static file #209

Open glasserc opened 4 years ago

glasserc commented 4 years ago

In my project, I have a registration flow that takes the user to a URL like http://localhost:8080/awaiting-confirmation/username@example.com. Doing pushUrl from the Elm side works fine. However, refreshing this page in the browser causes an error: Cannot GET /awaiting-confirmation/username@example.com.

I believe this is due to the code here that analyzes the URL to determine what file type the request is trying to get, in order to determine whether to try to serve a static file or to serve the root page:

https://github.com/wking-io/elm-live/blob/e9af6ecee3a8b1ea9261927a1e6c7377505aab3f/lib/src/start.js#L109-L110

Because this is guessing based on the "extension", any URL that ends in .com is assumed to be a static file.

At first I thought this was a problem with the URL parsing in the path component of a URL, so I also tried as a query string: http://localhost:8080/awaiting-confirmation?email=username@example.com. Unfortunately this gave me the same result (Cannot GET /awaiting-confirmation). I don't like the behavior on just paths, but I think the same behavior on query parameters is definitely wrong.

I can think of a few ways we could try to fix this:

wking-io commented 4 years ago

This is a very good point and something that I didn't have a lot of cases to test the edges of. Would love your thoughts on solutions for this in the code. :)