-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@astrojs/sitemap: Fixes generated URLs when using a
base
with a SSR…
… adapter (#9704) * Fix base path formatting for ssr adapters * Update .changeset/curly-seals-count.md Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> --------- Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
- Loading branch information
1 parent
96bfc4b
commit b325fad
Showing
3 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@astrojs/sitemap": patch | ||
--- | ||
|
||
Fixes generated URLs when using a `base` with a SSR adapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { loadFixture, readXML } from './test-utils.js'; | ||
import { expect } from 'chai'; | ||
|
||
describe('URLs with base path', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
describe('using node adapter', () => { | ||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/ssr/', | ||
base: '/base', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Base path is concatenated correctly', async () => { | ||
const data = await readXML(fixture.readFile('/client/sitemap-0.xml')); | ||
const urls = data.urlset.url; | ||
expect(urls[0].loc[0]).to.equal('http://example.com/base/one/'); | ||
}); | ||
}); | ||
|
||
describe('static', () => { | ||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/static/', | ||
base: '/base', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Base path is concatenated correctly', async () => { | ||
const data = await readXML(fixture.readFile('/sitemap-0.xml')); | ||
const urls = data.urlset.url; | ||
expect(urls[0].loc[0]).to.equal('http://example.com/base/123/'); | ||
}); | ||
}); | ||
}); |