Skip to content

Commit

Permalink
Fix regex in collection file path matcher
Browse files Browse the repository at this point in the history
As per #211
  • Loading branch information
kyoshino committed Sep 29, 2024
1 parent 0275380 commit a2f1f47
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/services/contents/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ export const parseEntryFiles = (entryFiles) => {
/**
* The path pattern in the middle, which should match the filename (without extension),
* possibly with the parent directory. If the collection’s `path` is configured, use it to
* generate a pattern.
* generate a pattern, so that unrelated files are excluded.
* @see https://decapcms.org/docs/collection-folder/#folder-collections-path
*/
const filePathMatcher =
collection.path?.replace(/{{.+?}}/g, '.+?').replace(/\//g, '\\/') ?? '.+';
collection.path?.replace(/\//g, '\\/').replace(/{{.+?}}/g, '[^\\/]+') ?? '.+';
const regex = new RegExp(
`^${escapeRegExp(stripSlashes(configFolderPath))}\\/(${filePathMatcher})\\.${extension}$`,
Expand Down

0 comments on commit a2f1f47

Please sign in to comment.