Access to fragment in router state on page refresh (#131123)

This PR fixes the issue #108614 
Particularly this behaviour https://github.com/flutter/flutter/issues/108614#issuecomment-1645231915
This commit is contained in:
Vasiliy Ditsyak
2023-09-18 23:12:08 +02:00
committed by GitHub
parent da0f9a997a
commit 43407cf155
3 changed files with 33 additions and 4 deletions

View File

@@ -80,17 +80,34 @@ void main() {
expect(strategy.getPath(), '/bar');
});
test('gets path correctly in the presence of query params', () {
test('gets path correctly in the presence of query params and omits fragment if no flag specified', () {
location.baseHref = 'https://example.com/foo/';
location.pathname = '/foo/bar';
final PathUrlStrategy strategy = PathUrlStrategy(location);
location.search = '?q=1';
expect(strategy.getPath(), '/bar?q=1');
location.search = '?q=1&t=r';
expect(strategy.getPath(), '/bar?q=1&t=r');
location.hash = '#fragment=1';
expect(strategy.getPath(), '/bar?q=1&t=r');
});
test('gets path correctly in the presence of query params and fragment', () {
location.baseHref = 'https://example.com/foo/';
location.pathname = '/foo/bar';
final PathUrlStrategy strategy = PathUrlStrategy(location, true);
location.search = '?q=1';
expect(strategy.getPath(), '/bar?q=1');
location.search = '?q=1&t=r';
expect(strategy.getPath(), '/bar?q=1&t=r');
location.hash = '#fragment=1';
expect(strategy.getPath(), '/bar?q=1&t=r#fragment=1');
});
test('empty route name is ok', () {