diff --git a/packages/web-components/src/components/masthead/__stories__/links.ts b/packages/web-components/src/components/masthead/__stories__/links.ts
index ea523f1aaf7..e8ac7664cc7 100644
--- a/packages/web-components/src/components/masthead/__stories__/links.ts
+++ b/packages/web-components/src/components/masthead/__stories__/links.ts
@@ -88,7 +88,7 @@ const mastheadL1Data: MastheadL1 = {
submenu: {
columns: 2,
announcement:
- 'Lorem ipsum: Full announcement may be linked or only a portion as an inline link',
+ 'Lorem ipsum: Full announcement may be linked or only a portion as an inline link',
footer: {
title: 'View all lorem ipsum (B)',
url: 'https://example.com',
@@ -145,7 +145,7 @@ const mastheadL1Data: MastheadL1 = {
submenu: {
columns: 3,
announcement:
- 'Lorem ipsum: Full announcement may be linked or only a portion as an inline link',
+ 'Lorem ipsum: Full announcement may be linked or only a portion as an inline link',
menuSections: [
{
span: 1,
@@ -236,7 +236,7 @@ const mastheadL1Data: MastheadL1 = {
submenu: {
columns: 3,
announcement:
- 'Lorem ipsum: Full announcement may be linked or only a portion as an inline link',
+ 'Lorem ipsum: Full announcement may be linked or only a portion as an inline link',
menuSections: [
{
span: 1,
@@ -407,7 +407,7 @@ const mastheadL1Data: MastheadL1 = {
submenu: {
columns: 2,
announcement:
- 'Lorem ipsum: Full announcement may be linked or only a portion as an inline link',
+ 'Lorem ipsum: Full announcement may be linked or only a portion as an inline link',
footer: {
title: 'View all lorem ipsum (E)',
url: 'https://example.com',
diff --git a/packages/web-components/src/components/masthead/masthead-l1.ts b/packages/web-components/src/components/masthead/masthead-l1.ts
index 17c6c8247a5..5d0f1a891e3 100644
--- a/packages/web-components/src/components/masthead/masthead-l1.ts
+++ b/packages/web-components/src/components/masthead/masthead-l1.ts
@@ -933,9 +933,19 @@ class C4DMastheadL1 extends StableSelectorMixin(LitElement) {
}
// Fall back to automated selection based on URL.
else {
- this.selectedElements = allLinks.filter(
- (el) => el.href === currentUrlPath
- );
+ this.selectedElements = allLinks.filter((el) => {
+ try {
+ const elURL = new URL(el.href);
+ const currURL = new URL(currentUrlPath || '');
+
+ // Compare url without query params.
+ return (
+ elURL.host === currURL.host && elURL.pathname === currURL.pathname
+ );
+ } catch (_error) {
+ return false;
+ }
+ });
}
if (this.selectedElements.length) {