mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
[ci] format
This commit is contained in:
parent
ec7d2ebbd9
commit
8e51bf9ea9
2 changed files with 8 additions and 9 deletions
|
@ -98,8 +98,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => {
|
||||||
.map((p) => {
|
.map((p) => {
|
||||||
if (p.pathname !== '' && !finalSiteUrl.pathname.endsWith('/'))
|
if (p.pathname !== '' && !finalSiteUrl.pathname.endsWith('/'))
|
||||||
finalSiteUrl.pathname += '/';
|
finalSiteUrl.pathname += '/';
|
||||||
if (p.pathname.startsWith('/'))
|
if (p.pathname.startsWith('/')) p.pathname = p.pathname.slice(1);
|
||||||
p.pathname = p.pathname.slice(1);
|
|
||||||
const fullPath = finalSiteUrl.pathname + p.pathname;
|
const fullPath = finalSiteUrl.pathname + p.pathname;
|
||||||
return new URL(fullPath, finalSiteUrl).href;
|
return new URL(fullPath, finalSiteUrl).href;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
import {before, describe, it} from "node:test";
|
import { before, describe, it } from 'node:test';
|
||||||
import {loadFixture, readXML} from "./test-utils.js";
|
import { loadFixture, readXML } from './test-utils.js';
|
||||||
import assert from "node:assert/strict";
|
import assert from 'node:assert/strict';
|
||||||
|
|
||||||
describe('Dynamic with rest parameter', () => {
|
describe('Dynamic with rest parameter', () => {
|
||||||
/** @type {import('./test-utils.js').Fixture} */
|
/** @type {import('./test-utils.js').Fixture} */
|
||||||
let fixture;
|
let fixture;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
root: './fixtures/dynamic',
|
root: './fixtures/dynamic',
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should generate correct urls', async () => {
|
it('Should generate correct urls', async () => {
|
||||||
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
|
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
|
||||||
const urls = data.urlset.url.map((url) => url.loc[0]);
|
const urls = data.urlset.url.map((url) => url.loc[0]);
|
||||||
|
|
||||||
assert.ok(urls.includes('http://example.com/'));
|
assert.ok(urls.includes('http://example.com/'));
|
||||||
assert.ok(urls.includes('http://example.com/blog/'));
|
assert.ok(urls.includes('http://example.com/blog/'));
|
||||||
assert.ok(urls.includes('http://example.com/test/'));
|
assert.ok(urls.includes('http://example.com/test/'));
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
Loading…
Reference in a new issue