[ci] format
This commit is contained in:
parent
e0f838ca39
commit
abcee7c957
2 changed files with 10 additions and 14 deletions
|
@ -29,17 +29,13 @@ export function getParams(array: string[]) {
|
||||||
*/
|
*/
|
||||||
export function stringifyParams(params: Params) {
|
export function stringifyParams(params: Params) {
|
||||||
// validate parameter values then stringify each value
|
// validate parameter values then stringify each value
|
||||||
const validatedParams = Object.entries(params)
|
const validatedParams = Object.entries(params).reduce((acc, next) => {
|
||||||
.reduce((acc, next) => {
|
validateGetStaticPathsParameter(next);
|
||||||
validateGetStaticPathsParameter(next);
|
const [key, value] = next;
|
||||||
const [key, value] = next;
|
acc[key] = `${value}`;
|
||||||
acc[key] = `${value}`;
|
return acc;
|
||||||
return acc;
|
}, {} as Params);
|
||||||
}, {} as Params);
|
|
||||||
|
|
||||||
// Always sort keys before stringifying to make sure objects match regardless of parameter ordering
|
// Always sort keys before stringifying to make sure objects match regardless of parameter ordering
|
||||||
return JSON.stringify(
|
return JSON.stringify(validatedParams, Object.keys(params).sort());
|
||||||
validatedParams,
|
}
|
||||||
Object.keys(params).sort()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
@ -69,5 +69,5 @@ describe('getStaticPaths - route params type validation', () => {
|
||||||
// route provided with { params: { year: 2022, slug: "post-2" }}
|
// route provided with { params: { year: 2022, slug: "post-2" }}
|
||||||
const res = await fixture.fetch('/blog/2022/post-2');
|
const res = await fixture.fetch('/blog/2022/post-2');
|
||||||
expect(res.status).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
Loading…
Reference in a new issue