Skip to content

[flutter_web_plugins] HashUrlStrategy drops/overwrites query parameters #116415

@Bungeefan

Description

@Bungeefan

This code ignores the pathname and query parameters (search), if there is an internalUrl.

Before initial routing:
http://localhost:45389/?example=true
After routing:
http://localhost:45389/#/menu
After routing (with fix):
http://localhost:45389/?example=true#/menu

return internalUrl.isEmpty
? '${_platformLocation.pathname}${_platformLocation.search}'
: '#$internalUrl';

In our use case, it would be important to keep these parameters in the URL, even when routing in Flutter.
And as with other technologies (e.g. React Router), the parameters remain unchanged, and the hash routing is appended.

Example fix:

return "${_platformLocation.pathname}${_platformLocation.search}${internalUrl.isEmpty ? '' : '#$internalUrl'}";

Workaround:
Extend HashUrlStrategy with the fix and set it via setUrlStrategy from flutter_web_plugins.

Metadata

Metadata

Assignees

Labels

assigned for triageissue is assigned to a domain expert for further triagef: routesNavigator, Router, and related APIs.found in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions