Add id-edb after release if we can't do anything else
This commit is contained in:
parent
c86fb77f9e
commit
8e4239893c
1 changed files with 17 additions and 3 deletions
|
|
@ -12,11 +12,18 @@ const existingEmptyEDBIDParameter = /^(\s*\|\s*id-edb\s*=)\s*$/m;
|
|||
|
||||
/**
|
||||
* Matches an `id-gt` infobox parameter above which we can insert an `id-edb`
|
||||
* parameter above. Whitespace in capture groups so the inserted parameter can
|
||||
* use the exact same formatting.
|
||||
* parameter. Whitespace in capture groups so the inserted parameter can use the
|
||||
* exact same formatting.
|
||||
*/
|
||||
const existingGTIDParameter = /^(\s*)\|(\s*)id-gt(\s*)=(\s*).*$/m;
|
||||
|
||||
/**
|
||||
* Matches a `release` infobox parameter below which we can insert an `id-edb`
|
||||
* parameter. Whitespace in capture groups so the inserted parameter can use the
|
||||
* exact same formatting.
|
||||
*/
|
||||
const existingReleaseParameter = /^(\s*)\|(\s*)release(\s*)=(\s*).*$/m;
|
||||
|
||||
/**
|
||||
* Inserts the `id-edb` item infobox parameter into the given page contents.
|
||||
* @param {string} pageContent
|
||||
|
|
@ -36,7 +43,14 @@ function insertInfoboxEDBID (pageContent, edbID) {
|
|||
console.log('Page has `id-gt` parameter, inserting `id-edb` above that');
|
||||
return pageContent.replace(existingGTIDParameter, `$1|$2id-edb$3=$4${edbID}\n$&`);
|
||||
}
|
||||
console.log('bad', pageContent);
|
||||
if (pageContent.match(existingReleaseParameter)) {
|
||||
console.log('Page has no ID parameters, inserting `id-edb` below `release`');
|
||||
return pageContent.replace(existingReleaseParameter, `$&\n$1|$2id-edb$3=$4${edbID}`)
|
||||
}
|
||||
|
||||
console.group('Bad page content:');
|
||||
console.log(pageContent);
|
||||
console.groupEnd();
|
||||
throw new Error('Dunno how to insert the parameter into this page');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue