diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts index f6ddbe7b37a67..0814ae0e1a3d8 100644 --- a/packages/integrations/sitemap/src/index.ts +++ b/packages/integrations/sitemap/src/index.ts @@ -95,8 +95,16 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { * because `finalSiteUrl` always has trailing slash */ const path = finalSiteUrl.pathname + r.generate(r.pathname).substring(1); - const newUrl = new URL(path, finalSiteUrl).href; - urls.push(newUrl); + + let newUrl = new URL(path, finalSiteUrl).href; + + if (config.trailingSlash === 'never') { + urls.push(newUrl); + } else if (config.build.format === 'directory' && !newUrl.endsWith('/')) { + urls.push(newUrl + '/'); + } else { + urls.push(newUrl); + } } return urls; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d10ef3497fd48..b9e26faca0177 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -680,7 +680,7 @@ importers: version: 3.0.1 typescript: specifier: '*' - version: 4.9.5 + version: 5.0.2 unist-util-visit: specifier: ^4.1.0 version: 4.1.0 @@ -15607,7 +15607,7 @@ packages: shiki: 0.10.1 shiki-twoslash: 3.1.0 tslib: 2.1.0 - typescript: 4.9.5 + typescript: 5.0.2 unist-util-visit: 2.0.3 transitivePeerDependencies: - supports-color @@ -16910,11 +16910,6 @@ packages: for-each: 0.3.3 is-typed-array: 1.1.10 - /typescript@4.9.5: - resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} - engines: {node: '>=4.2.0'} - hasBin: true - /typescript@5.0.2: resolution: {integrity: sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==} engines: {node: '>=12.20'}