Skip to content

Commit a0405fa

Browse files
committed
environment behaviors
1 parent 973c6d3 commit a0405fa

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

  • themes/arm-design-system-hugo-theme/static/js/eco-dashboard

themes/arm-design-system-hugo-theme/static/js/eco-dashboard/search.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ function normalizePackageName(input) {
5858
.toLowerCase(); // Convert to lowercase
5959
}
6060

61+
function shouldUseTrailingSlashForPackageUrl() {
62+
const currentHost = window.location.hostname.toLowerCase();
63+
return currentHost.includes('cloudfront.net');
64+
}
65+
6166
function getDashboardPath(dashboardPath) {
6267
let normalizedPath = dashboardPath;
6368

@@ -74,7 +79,13 @@ function getDashboardPath(dashboardPath) {
7479
normalizedPath = '/' + normalizedPath;
7580
}
7681

77-
return normalizedPath.replace(/\/$/, '') || '/';
82+
normalizedPath = normalizedPath.replace(/\/+$/, '') || '/';
83+
84+
if (normalizedPath !== '/' && shouldUseTrailingSlashForPackageUrl()) {
85+
normalizedPath = normalizedPath + '/';
86+
}
87+
88+
return normalizedPath;
7889
}
7990

8091
function normalizeDashboardUrlInAddressBar() {
@@ -83,7 +94,11 @@ function normalizeDashboardUrlInAddressBar() {
8394
return;
8495
}
8596

86-
const normalizedPath = currentPath.replace(/\/+$/, '') || '/';
97+
let normalizedPath = currentPath.replace(/\/+$/, '') || '/';
98+
if (normalizedPath !== '/' && shouldUseTrailingSlashForPackageUrl()) {
99+
normalizedPath = normalizedPath + '/';
100+
}
101+
87102
if (normalizedPath === currentPath) {
88103
return;
89104
}

0 commit comments

Comments
 (0)