mirror of
https://github.com/ItsVipra/ProToots
synced 2024-11-22 03:23:02 +00:00
Merge pull request #48 from ItsVipra/improve-pronoun-field-matching
Switch to a regex-only pronoun field matching
This commit is contained in:
commit
3fa73edddf
2 changed files with 7 additions and 6 deletions
|
@ -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, /(i )?go(es)? by/i];
|
||||
const knownPronounUrls = [
|
||||
/pronouns\.page\/(@(?<username>\w+))?:?(?<pronouns>[\w/:]+)?/,
|
||||
/pronouns\.within\.lgbt\/(?<pronouns>[\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;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,12 @@ const validFields = [
|
|||
"professional nouns",
|
||||
"pronomen",
|
||||
"Pronouns / Pronomen",
|
||||
"Pronomen (DE)",
|
||||
"Pronouns (EN)",
|
||||
"i go by",
|
||||
"go by",
|
||||
];
|
||||
const invalidFields = ["pronounciation"];
|
||||
const invalidFields = ["pronounciation", "pronomenverwaltung"];
|
||||
|
||||
for (const field of validFields) {
|
||||
extract(`${field} is extracted`, async () => {
|
||||
|
|
Loading…
Reference in a new issue