Improve handling of articles named 'Annexe'

This commit is contained in:
Emmanuel 2024-12-28 22:01:25 +01:00
parent dad66869ac
commit 3e8165ac4c

View file

@ -117,7 +117,7 @@ function articleNumberSegmentToPriorityAndNumber(
[...s].reduce((sum, letter) => sum * 256 + letter.charCodeAt(0), 0), [...s].reduce((sum, letter) => sum * 256 + letter.charCodeAt(0), 0),
], ],
[semelBisTerEtcRegExp, (s) => numberBySemelBisTerEtc[s] ?? 9999], [semelBisTerEtcRegExp, (s) => numberBySemelBisTerEtc[s] ?? 9999],
[/^Annexe article$/, () => 1], [/^Annexe/, () => 1],
] as Array<[RegExp, (s: string) => number]> ] as Array<[RegExp, (s: string) => number]>
).entries()) { ).entries()) {
if (regExp.test(segment)) { if (regExp.test(segment)) {
@ -142,7 +142,7 @@ function splitArticleNumber(articleNumber: string): string[] {
.filter((segment) => segment !== "") .filter((segment) => segment !== "")
.map((segment) => segment.replace(/^1er$/, "1")) .map((segment) => segment.replace(/^1er$/, "1"))
if (annexe) { if (annexe) {
segments.push("Annexe article") segments.push("Annexe")
} }
return segments.reduce((segments: string[], segment: string) => { return segments.reduce((segments: string[], segment: string) => {
if (/^[A-Z]{2,3}$/.test(segment)) { if (/^[A-Z]{2,3}$/.test(segment)) {