mrpmorris / Fluxor

Fluxor is a zero boilerplate Flux/Redux library for Microsoft .NET and Blazor.
MIT License
1.22k stars 139 forks source link

GoAction using relative path doesn't work anymore (LocationChangeException) #497

Open yveslaurentcreton opened 2 weeks ago

yveslaurentcreton commented 2 weeks ago

When dispatching a GoAction with a relative path, the following exception is thrown:

Error: Microsoft.AspNetCore.Components.LocationChangeException: An exception occurred while dispatching a location changed event.
 ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at Fluxor.Blazor.Web.Middlewares.Routing.UrlComparer.AreEqual(String first, String second) in C:\Data\Mine\Code\Fluxor\Source\Lib\Fluxor.Blazor.Web\Middlewares\Routing\UrlComparer.cs:line 8
   at Fluxor.Blazor.Web.Middlewares.Routing.RoutingMiddleware.LocationChanged(Object sender, LocationChangedEventArgs e) in C:\Data\Mine\Code\Fluxor\Source\Lib\Fluxor.Blazor.Web\Middlewares\Routing\RoutingMiddleware.cs:line 47
   at Microsoft.AspNetCore.Components.NavigationManager.NotifyLocationChanged(Boolean isInterceptedLink)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Components.NavigationManager.NotifyLocationChanged(Boolean isInterceptedLink)
   at Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost.<>c__DisplayClass51_0.<OnLocationChangedAsync>b__1()
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<InvokeAsync>g__Execute|8_0(ValueTuple`3 state)
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost.OnLocationChangedAsync(String uri, String state, Boolean intercepted)

This is due to a recent change with commit 440c592d06982d8b068bdab67aa305355cea895d.

The code introduced the new assumption that the two parts are always valid URIs. When using a relative path, this causes issues.

This fix ensures that only absolute paths are compared.

Created PR #496

JeremyVm commented 1 week ago

Having the same issue. Hope the PR gets accepted.

gcalabro-rli commented 3 days ago

Same here, seems like low hanging fruit. Can we get this approved @mrpmorris ?