Allow whitespace when fetching pronouns from bio

This commit is contained in:
nachtjasmin 2023-07-12 17:41:08 +02:00
parent 854a597e56
commit 431dcd4bc6
No known key found for this signature in database
2 changed files with 4 additions and 3 deletions

View file

@ -216,10 +216,10 @@ const knownPronouns = [
* @returns {string|null} The result or null
*/
function extractFromBio(bio) {
const exactMatches = bio.matchAll(/(\w+)\/(\w+)/gi);
const exactMatches = bio.matchAll(/(\w+) ?\/ ?(\w+)/gi);
for (const [match, subjective, objective] of exactMatches) {
if (knownPronouns.includes(subjective) && knownPronouns.includes(objective)) {
return match;
return match.replaceAll(" ", "");
}
}

View file

@ -77,7 +77,8 @@ const bioExtractTests = [
["I'm cute and my pronouns are she/her", "she/her"], // exact match
["my pronouns are helicopter/joke", null], // not on allowlist
["pronouns: uwu/owo", "uwu/owo"], // followed by pronoun pattern
["pronouns: any", "any"], // followed by pronoun pattern,
["pronouns: any", "any"], // followed by pronoun pattern
["I'm cute af (she / they)", "she/they"], // with whitespace between pronouns
];
for (const [input, expects] of bioExtractTests) {
bioExtractSuite(input, async () => {