Skip to content
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

Multiple location changes from routing middleware when URL contains escaped sequences #297

Closed
uhfath opened this issue May 5, 2022 · 0 comments
Milestone

Comments

@uhfath
Copy link
Contributor

uhfath commented May 5, 2022

Here is a repro.
To reproduce:

  1. open development console;
  2. navigate to "Counter" page;
  3. clear console;
  4. enter Test in the input box and press enter;
  5. note the console log showing the sequence of events: SAVE -> PARAMS -> LOCATION;
  6. reload the page;
  7. note the sequence: INIT -> PARAMS;
  8. clear the console again;
  9. now edit the input box with some international text like Тест (this one is in Russian language, so just copy-paste) and press enter;
  10. not the change in sequence: SAVE -> PARAMS -> LOCATION (2) (called two times);
  11. reload the page;
  12. note the sequence: INIT -> PARAMS -> LOCATION;

The issue is 10 and 12.
In 10 there should be only one location change just like in 5.
And in 12 there should be no location change at all, just like in 7.

Double location changes lead to multiple records in browser history so when a user presses back he is not navigated actually back in history because history is doubled and sometimes tripled.

My guess is that the issue is this:

if (fullUri.ToString() != NavigationManager.Uri || action.ForceLoad)

The Uri might be unescaping the URL it contains whereas NavigationManager.Uri returns it as escaped sequence. Hence the difference.

Perhaps something like this would be better?

var isUriSame = string.Equals(uri.TrimEnd('/'), NavigationManager.Uri.TrimEnd('/'), StringComparison.OrdinalIgnoreCase)

In this case any irrelevant differences won't trigger location changing.

@mrpmorris mrpmorris added this to the 5.4 milestone May 8, 2022
@mrpmorris mrpmorris mentioned this issue May 17, 2022
mrpmorris added a commit that referenced this issue May 17, 2022
 * ActionSubscribers are now notified after state has been reduced ([#299](#299))
 * Routing middleware will no longer dispatch a GoAction when URl is the same value but formatted differently ([#297](#297))
 * `IDispatcher` now queues actions whenever there are no subscribers to the `ActionDispatched` event and then
   dequeues them when a subscriber is added ([#301](#301))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants