Skip to content

Commit 7d1690b

Browse files
committed
[repo] Normalise slugs when syncing with Wikimedia
1 parent 61bc0d4 commit 7d1690b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

scripts/utils.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,9 @@ const getUpdateMigratedPages = (logger) => (client) => async () => {
308308
const migratedPageData = yaml.load(await readFile(getMigrationPagePath(), 'utf8'));
309309

310310
const getDocIdList = (newDocIds) => {
311-
if (Array.isArray(newDocIds)) {
312-
return newDocIds.map((newDoc) => newDoc.slug);
313-
}
314-
315-
return [newDocIds.slug];
311+
// Ensure that doc ids always have a single leading slash.
312+
const ids = Array.isArray(newDocIds) ? newDocIds : [newDocIds];
313+
return ids.map((newDoc) => newDoc.slug.replace(/^\/*/, '/'));
316314
};
317315

318316
const getCurrentMigratedIdsForPage = (pageTitle) => getGetMigratedPageIds(logger)(client)(pageTitle);

0 commit comments

Comments
 (0)