ng-hub-ui-nav 22.9.0 → 22.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -678,7 +678,7 @@ class HubNavStateService {
|
|
|
678
678
|
if (!route) {
|
|
679
679
|
return true;
|
|
680
680
|
}
|
|
681
|
-
const activePath = activeRoute.split('#')[0].split('?')[0];
|
|
681
|
+
const activePath = this.normalizePath(activeRoute.split('#')[0].split('?')[0]);
|
|
682
682
|
if (route === activePath) {
|
|
683
683
|
return true;
|
|
684
684
|
}
|
|
@@ -697,7 +697,22 @@ class HubNavStateService {
|
|
|
697
697
|
if (!item.route) {
|
|
698
698
|
return null;
|
|
699
699
|
}
|
|
700
|
-
return Array.isArray(item.route) ? item.route.join('/') : item.route;
|
|
700
|
+
return this.normalizePath(Array.isArray(item.route) ? item.route.join('/') : item.route);
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* A path in the one form these comparisons can trust: no trailing slash, except for the root.
|
|
704
|
+
*
|
|
705
|
+
* `/products` and `/products/` are the same place, and an application is free to decide which
|
|
706
|
+
* one it puts in the address bar — a canonical trailing-slash `UrlSerializer` is a common SEO
|
|
707
|
+
* choice. Comparing the two as raw strings makes the nav's marking depend on that choice:
|
|
708
|
+
* every item whose route was declared without the slash silently stopped matching, and only
|
|
709
|
+
* the ancestors stayed lit, because their prefix test happens to tolerate it.
|
|
710
|
+
*
|
|
711
|
+
* @param path - A route path, in either form.
|
|
712
|
+
* @returns The path without its trailing slash.
|
|
713
|
+
*/
|
|
714
|
+
normalizePath(path) {
|
|
715
|
+
return path.length > 1 && path.endsWith('/') ? path.slice(0, -1) : path;
|
|
701
716
|
}
|
|
702
717
|
/**
|
|
703
718
|
* Recursively checks whether the given item or any of its descendants
|
|
@@ -719,9 +734,9 @@ class HubNavStateService {
|
|
|
719
734
|
*/
|
|
720
735
|
isItemOrDescendantActive(item, activeRoute) {
|
|
721
736
|
if (item.route) {
|
|
722
|
-
const route =
|
|
737
|
+
const route = this.routeOf(item);
|
|
723
738
|
const [pathAndQuery, activeFragment] = activeRoute.split('#');
|
|
724
|
-
const activePath = pathAndQuery.split('?')[0];
|
|
739
|
+
const activePath = this.normalizePath(pathAndQuery.split('?')[0]);
|
|
725
740
|
if (route === activePath) {
|
|
726
741
|
// When an item defines a fragment, require exact fragment match.
|
|
727
742
|
if (item.fragment) {
|