elmish / browser

Routing and Navigation for browser apps
https://elmish.github.io/browser
Other
35 stars 20 forks source link

MapInit error #55

Closed tforkmann closed 1 year ago

tforkmann commented 1 year ago

Hi there,

updating to the newest Elmish (4.0.0-beta-8) produces following error:

String.js:522 Uncaught (in promise) Error: Invalid startIndex and/or length at substring (String.js:522:15) at parseParams (parser.fs.js:274:72) at parsePath (parser.fs.js:5:56) at urlParser (Pages.js:197:21) at init (navigation.fs.js:96:56) at Program$4.init (Util.js:552:12) at traceInit (program.fs.js:66:38) at init (debugger.fs.js:36:30) at Util.js:552:12 at mapInit (App.js:2909:42)

I didn't make any changes from the version 3 to version 4 yet.

image

Any idea how to fix that?

et1975 commented 1 year ago

Hm, there was this fix...

tforkmann commented 1 year ago

Hmm that fix was for hashes right?

tforkmann commented 1 year ago

I guess it would need the same fix of parsePath instead of parseHash. Gonna try to create a PR.

et1975 commented 1 year ago

@alfonsogarciacaro I've created a unit test that passes (w/ or w/o the check in line 357) when running in CLR, which tells me the substring impl in JS doesn't work the same way as String.Substring - JS throws exception if start position points at the end, while .NET - returns empty string. Do you think this should be addressed in Fable core?

et1975 commented 1 year ago

will release a fix in urlParser 1.0.1.

alfonsogarciacaro commented 1 year ago

@et1975 The substring implementation seems to be right in Fable (it will return an empty string if startIndex is same as length). Maybe the error is caused by something else?