Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<tbody id="sw-tablebody">
{{ $id_index := 0}}
{{ $os := .context.Params.os }}
{{ $dashboard_page_path := .context.RelPermalink }}
{{ $dashboard_page_path := .context.RelPermalink | strings.TrimRight "/" }}
{{ if eq .context.Site.BaseURL "/" }}
{{ $base_path := (.context.Site.Params.dashboard_base_path | default "/ecosystem-dashboard") | strings.TrimRight "/" }}
{{ if ne $base_path "" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ function normalizePackageName(input) {
.toLowerCase(); // Convert to lowercase
}

function shouldUseTrailingSlashForPackageUrl() {
const currentHost = window.location.hostname.toLowerCase();
return currentHost.includes('cloudfront.net');
}

function getDashboardPath(dashboardPath) {
let normalizedPath = dashboardPath;

Expand All @@ -74,12 +79,36 @@ function getDashboardPath(dashboardPath) {
normalizedPath = '/' + normalizedPath;
}

if (!normalizedPath.endsWith('/')) {
normalizedPath = normalizedPath.replace(/\/+$/, '') || '/';

if (normalizedPath !== '/' && shouldUseTrailingSlashForPackageUrl()) {
normalizedPath = normalizedPath + '/';
}

return normalizedPath;
}

function normalizeDashboardUrlInAddressBar() {
const currentPath = window.location.pathname;
if (!currentPath || currentPath === '/') {
return;
}

let normalizedPath = currentPath.replace(/\/+$/, '') || '/';
if (normalizedPath !== '/' && shouldUseTrailingSlashForPackageUrl()) {
normalizedPath = normalizedPath + '/';
}

if (normalizedPath === currentPath) {
return;
}

window.history.replaceState(
window.history.state,
'',
normalizedPath + window.location.search + window.location.hash
);
}

function buildPackageDashboardUrl(packageSlug, dashboardPath) {
const packageUrl = new URL(window.location.href);
Expand Down Expand Up @@ -755,6 +784,8 @@ function ifNeededMoveFiltersToMobileOrDesktop(state_is_below_breakpoint) {
*/
document.addEventListener("DOMContentLoaded", function () {

normalizeDashboardUrlInAddressBar();



// 1
Expand Down
Loading