Skip to content

Commit

Permalink
fix: sanitize dots in path collection config (decaporg#3518)
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah authored and vladdu committed Jan 26, 2021
1 parent 25212da commit 52e54fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/netlify-cms-core/src/lib/__tests__/formatters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/netlify-cms-core/src/lib/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down

0 comments on commit 52e54fd

Please sign in to comment.