diff options
author | 2023-01-23 20:13:06 +0530 | |
---|---|---|
committer | 2023-01-23 09:43:06 -0500 | |
commit | 77ae7a597a8fdd5c939291b4f63237c659a79225 (patch) | |
tree | db955c488df41c33b9e322439a1cdad9b71d294a | |
parent | 46ecd5de34df619e2ee73ccea39a57acd37bc0b8 (diff) | |
download | astro-77ae7a597a8fdd5c939291b4f63237c659a79225.tar.gz astro-77ae7a597a8fdd5c939291b4f63237c659a79225.tar.zst astro-77ae7a597a8fdd5c939291b4f63237c659a79225.zip |
fix: trailingSlash with base breaking partytown file path (#5936)
* fix: trailingSlash with base breaking partytown file path
* Update index.ts
* Update index.ts
* Update index.ts
* fix lint
* Update index.ts
-rw-r--r-- | .changeset/beige-waves-wave.md | 5 | ||||
-rw-r--r-- | packages/integrations/partytown/src/index.ts | 6 |
2 files changed, 10 insertions, 1 deletions
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 }); |