Switch to a regex-only pronoun field matching

This commit is contained in:
nachtjasmin 2023-07-16 11:20:55 +02:00
parent 0240489456
commit 9d8c0332be
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View file

@ -1,6 +1,6 @@
import sanitizeHtml from "sanitize-html";
const fieldMatchers = [/\bpro.*nouns?\b/i, "pronomen"];
const fieldMatchers = [/\bpro.*nouns?\b/i, /\bpronomen\b/i];
const knownPronounUrls = [
/pronouns\.page\/:?([\w/@]+)/,
/pronouns\.within\.lgbt\/([\w/]+)/,
@ -44,10 +44,7 @@ export async function extractFromStatus(status) {
async function extractFromField(field) {
let pronounsRaw;
for (const matcher of fieldMatchers) {
if (typeof matcher === "string" && field.name.toLowerCase().includes(matcher)) {
pronounsRaw = field.value;
break;
} else if (field.name.match(matcher)) {
if (field.name.match(matcher)) {
pronounsRaw = field.value;
break;
}

View file

@ -10,8 +10,10 @@ const validFields = [
"professional nouns",
"pronomen",
"Pronouns / Pronomen",
"Pronomen (DE)",
"Pronouns (EN)",
];
const invalidFields = ["pronounciation"];
const invalidFields = ["pronounciation", "pronomenverwaltung"];
for (const field of validFields) {
extract(`${field} is extracted`, async () => {