cars: keep MAZDA2/JAECOO7 names (no false typo strip), canonical upload.wikimedia.org thumbs, tidier gallery captions/credits
All checks were successful
Deploy production / deploy (push) Successful in 2m34s

This commit is contained in:
2026-10-24 16:54:14 +00:00
parent bf0a1e1d2a
commit 7636f0b2bc
3 changed files with 49 additions and 20 deletions

View File

@@ -391,12 +391,16 @@ function cleanTradeName(raw: string, make: string): string {
else if (s.startsWith(`${make} `) && s.length > make.length + 1) s = s.slice(make.length + 1);
else break;
}
// Make glued to a number ("MAZDA2 HYBRID" -> "2 HYBRID", "JAECOO7" -> "7").
const mk0 = make.replace(/[^A-Z]/g, '');
const glued = s.match(new RegExp(`^${mk0}(\\d+)\\b(.*)$`));
if (mk0.length >= 3 && glued) s = `${glued[1]}${glued[2]}`;
// Misspelt make as first word ("PEUGOT 205" under PEUGEOT).
const [w0, ...restW] = s.split(' ');
const mk0 = make.replace(/[^A-Z]/g, '');
if (
restW.length &&
mk0.length >= 5 &&
/^[A-Z]+$/.test(w0) && // "MAZDA2 HYBRID" and "JAECOO7 PHEV" are names, not typos
w0 !== mk0 &&
w0.slice(0, 4) === mk0.slice(0, 4) &&
Math.abs(w0.length - mk0.length) <= 1

View File

@@ -405,7 +405,10 @@ function toPhoto(
file,
kind,
caption,
thumb: info.thumburl,
// Canonical host, no tracking query: https://upload.wikimedia.org/.../960px-<file>
thumb: info.thumburl
.replace(/\?.*$/, '')
.replace('//thumb.wikimedia.org/', '//upload.wikimedia.org/'),
width: info.width,
height: info.height,
author,