Closed Johnnybu closed 4 years ago
Thanks for the report, looking into it.
Can you give 3.0.3 a spin?
Wow, that was fast! :)
Sorry I took so long to get back to this. Also, Happy New year! I gave 3.0.3 a spin, and I can confirm parseHash now works for top-level url access. While I was at it, I took a look at the fix (curiosity), and noticed that parsePath may also be problematic - so I flipped my app over to that and got this:
Uncaught Error: Invalid startIndex and/or length
at substring (webpack-internal:///./.fable/fable-library.2.4.12/String.js:935)
at parseParams (webpack-internal:///./.fable/Fable.Elmish.Browser.3.0.3/parser.fs:299)
at parsePath (webpack-internal:///./.fable/Fable.Elmish.Browser.3.0.3/parser.fs:309)
at parser (webpack-internal:///./src/App.fs:180)
at init (webpack-internal:///./.fable/Fable.Elmish.Browser.3.0.3/navigation.fs:142)
at Elmish_Program.eval [as init] (webpack-internal:///./.fable/fable-library.2.4.12/Util.js:988)
at traceInit (webpack-internal:///./.fable/Fable.Elmish.3.0.6/program.fs:90)
at init (webpack-internal:///./.fable/Fable.Elmish.Debugger.3.0.3/debugger.fs:92)
at eval (webpack-internal:///./.fable/fable-library.2.4.12/Util.js:988)
at Elmish_Program.eval [as init] (webpack-internal:///./src/App.fs:381)
I wish I had got that in my initial report, but I am only using the hash parser right now, so I admittedly didn't think to try the path parser until now... :-\
Thanks, can you try 3.0.4 please?
That fixed it.
Description
The Fable-Compiler v2.4.12 update changed the way Substring works. It now throws an error.
The parseHash method relies on the JS substring behavior that returns an empty string when the index is greater than the input string length. This error prevents routed, browser-based Elmish apps from loading when a base URL is used for the first request.
Repro code
Line 352 of parser.fs:
let hash = location.hash.Substring 1
Throws this error:
When the application is accessed without a hash segment in the URL (e.g. the root url)
Expected and actual results
Application successfully loads without error when requested using the root URL
Related information