fix: strip trailing slash from BASE_URL to prevent double slashes in URLs

Agent-Logs-Url: https://github.com/samber/awesome-prometheus-alerts/sessions/c85937ba-1855-4b8a-a72b-847eab1c8639

Co-authored-by: samber <2951285+samber@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-10 19:00:43 +00:00 committed by GitHub
parent 79f4055dbb
commit b1764267dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 10 additions and 10 deletions

View file

@ -5,7 +5,7 @@ interface Props {
class?: string;
}
const { class: extraClass = '' } = Astro.props;
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
---
<div id="search" class={extraClass}></div>
@ -14,7 +14,7 @@ const base = import.meta.env.BASE_URL;
<script>
// Load Pagefind UI lazily (only when the search div is visible/focused)
function initPagefind() {
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
// @ts-ignore
import(`${base}/pagefind/pagefind-ui.js`).then((module) => {
const PagefindUI = module.PagefindUI;

View file

@ -31,7 +31,7 @@ const {
dateModified,
} = Astro.props;
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const canonical = canonicalUrl ?? `${SITE_ORIGIN}${base}${Astro.url.pathname.replace(base, '')}`;
---

View file

@ -27,7 +27,7 @@ interface Props {
}
const { title, description, breadcrumbs = [], icon = 'book', badge = 'Guide', extraJsonLd, dateUpdated, keywords, readingTime } = Astro.props;
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const canonicalUrl = `${SITE_ORIGIN}${base}${Astro.url.pathname.replace(base, '')}`;
const dateModified = dateUpdated ?? new Date().toISOString().slice(0, 10);

View file

@ -1,7 +1,7 @@
---
import GuideLayout from '../layouts/GuideLayout.astro';
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const howToJsonLd = {
'@context': 'https://schema.org',

View file

@ -1,7 +1,7 @@
---
import GuideLayout from '../layouts/GuideLayout.astro';
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const howToJsonLd = {
'@context': 'https://schema.org',

View file

@ -6,7 +6,7 @@ import SearchWidget from '../components/SearchWidget.astro';
import { data, getGroupSlug, getRuleCount, getTotalRuleCount, getTotalServiceCount, getPopularServices } from '../data/rules';
import { SITE_URL, GITHUB_URL, schemaAuthor, schemaPublisher, schemaWebSite, SITE_DATE_PUBLISHED, LICENSE_CC_BY_URL, LICENSE_MIT_URL } from '../data/site';
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const totalRules = getTotalRuleCount();
const totalServices = getTotalServiceCount();
const popularServices = getPopularServices();

View file

@ -15,7 +15,7 @@ export function getStaticPaths() {
}
const { group, service } = Astro.props;
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const groupSlug = getGroupSlug(group);
const serviceSlug = getServiceSlug(service);
const ruleCount = getRuleCount(service);

View file

@ -14,7 +14,7 @@ export function getStaticPaths() {
}
const { group } = Astro.props;
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const groupSlug = getGroupSlug(group);
const totalRules = group.services.reduce((sum, svc) => sum + getRuleCount(svc), 0);

View file

@ -6,7 +6,7 @@ import CautionBanner from '../../components/CautionBanner.astro';
import { data, getGroupSlug, getServiceSlug, getRuleCount, getTotalRuleCount, getTotalServiceCount, buildRedirectMap } from '../../data/rules';
import { SITE_URL, schemaWebSite } from '../../data/site';
const base = import.meta.env.BASE_URL;
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const totalRules = getTotalRuleCount();
const totalServices = getTotalServiceCount();
const redirectMap = buildRedirectMap(base);