diff --git a/.changeset/beige-waves-wave.md b/.changeset/beige-waves-wave.md new file mode 100644 index 000000000..690c37160 --- /dev/null +++ b/.changeset/beige-waves-wave.md @@ -0,0 +1,5 @@ +--- +'@astrojs/partytown': patch +--- + +fix trailing slash with base path diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts index eed0ab7c5..adeab75dd 100644 --- a/packages/integrations/partytown/src/index.ts +++ b/packages/integrations/partytown/src/index.ts @@ -17,6 +17,10 @@ type PartytownOptions = } | undefined; +function appendForwardSlash(str: string) { + return str.endsWith('/') ? str : str + '/'; +} + export default function createPlugin(options: PartytownOptions): AstroIntegration { let config: AstroConfig; let partytownSnippetHtml: string; @@ -26,7 +30,7 @@ export default function createPlugin(options: PartytownOptions): AstroIntegratio name: '@astrojs/partytown', hooks: { 'astro:config:setup': ({ config: _config, command, injectScript }) => { - const lib = `${_config.base}~partytown/`; + const lib = `${appendForwardSlash(_config.base)}~partytown/`; const forward = options?.config?.forward || []; const debug = options?.config?.debug || command === 'dev'; partytownSnippetHtml = partytownSnippet({ lib, debug, forward });