This repository was archived by the owner on Sep 16, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 44
55* Added ` canNavigate ` to ` RouterHook ` .
66
7+ * Navigation will no longer succeed for an empty path if it doesn't match a
8+ route.
9+
710## 2.0.0-alpha+13
811
912### New features
Original file line number Diff line number Diff line change @@ -182,7 +182,9 @@ class RouterImpl extends Router {
182182 }
183183
184184 MutableRouterState nextState = await _resolveState (path, navigationParams);
185- if (nextState == null ) {
185+ // In the event that `path` is empty and doesn't match any routes,
186+ // `_resolveState` will return a state with no routes, instead of null.
187+ if (nextState == null || nextState.routes.isEmpty) {
186188 return NavigationResult .INVALID_ROUTE ;
187189 }
188190
Original file line number Diff line number Diff line change 1+ @TestOn ('browser' )
2+ import 'package:angular/angular.dart' ;
3+ import 'package:angular_router/angular_router.dart' ;
4+ import 'package:angular_router/testing.dart' ;
5+ import 'package:angular_test/angular_test.dart' ;
6+ import 'package:test/test.dart' ;
7+
8+ // ignore: uri_has_not_been_generated
9+ import '1389_empty_path_test.template.dart' as ng;
10+
11+ void main () {
12+ tearDown (disposeAnyRunningTest);
13+
14+ test ('navigation to empty path should fail' , () async {
15+ final testBed =
16+ NgTestBed .forComponent <TestComponent >(ng.TestComponentNgFactory );
17+ final testFixture = await testBed.create ();
18+ final router = testFixture.assertOnlyInstance.router;
19+ final result = await router.navigate ('/' );
20+ expect (result, NavigationResult .INVALID_ROUTE );
21+ });
22+ }
23+
24+ @Component (
25+ selector: 'test' ,
26+ template: '' ,
27+ providers: routerProvidersTest,
28+ )
29+ class TestComponent {
30+ final Router router;
31+
32+ TestComponent (this .router);
33+ }
You can’t perform that action at this time.
0 commit comments