mirror of
https://github.com/ItsVipra/ProToots
synced 2024-11-10 06:04:20 +00:00
Allow whitespace when fetching pronouns from bio
This commit is contained in:
parent
854a597e56
commit
431dcd4bc6
2 changed files with 4 additions and 3 deletions
|
@ -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(" ", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
Loading…
Reference in a new issue