-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fable 4.0 breaks parseParams #25
Comments
That's strange. Did you only update Fable or also Elmish? Would it be possible to print the generated code for Fable 3 and Fable 4 for |
for the record: I don't think it's a fable compiler bug. |
This library doesn't work on |
Hello! I don't have any idea about the history of these projects, but I confirm there is currently an incompatibility between them:
The issue is that this I'm not sure what's the best approach to fix it, but I see two options:
This reimplementation of Based on the above, here is what I came up with (just for type private IUrlSearchParameters =
abstract entries : unit -> seq<string array>
[<Emit("new URLSearchParams($0)")>]
let private createUrlSearchParams (_queryString: string) : IUrlSearchParameters = jsNative
let parseHash (parser: Parser<_,_>) (location: Browser.Types.Location) =
let parseParams queryString =
try
let urlParams = createUrlSearchParams queryString
Map [ for entry in urlParams.entries() -> entry[0], entry[1] ]
with
| _ -> Map.empty
let hash, search =
let hash =
if location.hash.Length > 1 then location.hash.Substring(1)
else ""
if hash.Contains("?") then
let justHash = hash.Substring(0, hash.IndexOf("?"))
justHash, hash.Substring(justHash.Length)
else
hash, "?"
parse parser hash (parseParams search) It seems to work well as a workaround too, until this is fixed. |
Released fix in 1.0.2, please give it a spin. |
What about adding unit tests instead? :) |
Before the Fable 4.0 update we did:
let urlParser location = parsePath pageParser location
but now we have to do
It looks like the ? is no longer handled automatically.
/cc @et1975 @alfonsogarciacaro @MangelMaxime @tforkmann
The text was updated successfully, but these errors were encountered: