Skip to content

Commit

Permalink
fix: trailingSlash with base breaking partytown file path (#5936)
Browse files Browse the repository at this point in the history
* fix: trailingSlash with base breaking partytown file path

* Update index.ts

* Update index.ts

* Update index.ts

* fix lint

* Update index.ts
  • Loading branch information
Rishi Raj Jain committed Jan 23, 2023
1 parent 46ecd5d commit 77ae7a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/beige-waves-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/partytown': patch
---

fix trailing slash with base path
6 changes: 5 additions & 1 deletion packages/integrations/partytown/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 });
Expand Down

0 comments on commit 77ae7a5

Please sign in to comment.