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
This commit is contained in:
parent
46ecd5de34
commit
77ae7a597a
2 changed files with 10 additions and 1 deletions
5
.changeset/beige-waves-wave.md
Normal file
5
.changeset/beige-waves-wave.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/partytown': patch
|
||||
---
|
||||
|
||||
fix trailing slash with base path
|
|
@ -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 });
|
||||
|
|
Loading…
Reference in a new issue