fix(curriculum): ObjectID filename detection (#56837)

This commit is contained in:
Krzysztof G.
2024-10-25 16:16:16 +02:00
committed by GitHub
parent 76eae4effd
commit 63a4f08493

View File

@@ -275,12 +275,12 @@ function generateChallengeCreator(lang, englishPath, i18nPath) {
({ id }) => id === challenge.id
);
const isObjectIdFilename = /[a-z0-9]{24}\.md$/.test(englishPath);
const isObjectIdFilename = /\/[a-z0-9]{24}\.md$/.test(englishPath);
if (isObjectIdFilename) {
const filename = englishPath.split('/').pop();
if (filename !== `${challenge.id}.md`) {
throw Error(
`Filename ${filename} does not match challenge id ${challenge.id}`
`Filename matches MongoDB ObjectID pattern, but ${filename} does not match challenge id ${challenge.id}`
);
}
}