fix: sanitize dots in path collection config (#3518)
This commit is contained in:
parent
a8678559b2
commit
601175c6a1
@ -281,6 +281,21 @@ describe('formatters', () => {
|
||||
),
|
||||
).toBe('sub_dir/2020/2020-01-01-post-title.en');
|
||||
});
|
||||
|
||||
it(`should replace '.' in path with -`, () => {
|
||||
selectIdentifier.mockReturnValueOnce('title');
|
||||
|
||||
expect(
|
||||
slugFormatter(
|
||||
Map({
|
||||
slug: '{{slug}}.en',
|
||||
path: '../dir/{{slug}}',
|
||||
}),
|
||||
Map({ title: 'Post Title' }),
|
||||
slugConfig,
|
||||
),
|
||||
).toBe('--/dir/post-title.en');
|
||||
});
|
||||
});
|
||||
|
||||
describe('previewUrlFormatter', () => {
|
||||
|
@ -115,7 +115,7 @@ export const slugFormatter = (
|
||||
if (!collection.has('path')) {
|
||||
return slug;
|
||||
} else {
|
||||
const pathTemplate = collection.get('path') as string;
|
||||
const pathTemplate = prepareSlug(collection.get('path') as string);
|
||||
return compileStringTemplate(pathTemplate, date, slug, entryData, (value: string) =>
|
||||
value === slug ? value : processSegment(value),
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user