From b9211b8e7ba8c51ec00192d720581595660b2505 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Sat, 1 Jul 2023 18:48:47 +0200 Subject: [PATCH] (profile)(bug) fix flags link matching --- components/Flag.vue | 46 +++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/components/Flag.vue b/components/Flag.vue index 69c170611..aff20a925 100644 --- a/components/Flag.vue +++ b/components/Flag.vue @@ -60,8 +60,8 @@ const options = []; if (this.termkey) { options.push(this.termkey); - if (this.termkey === 'Polyamorous') { - options.push('Polyamory'); + if (this.termkey.endsWith('amorous')) { + options.push(this.termkey.replace('amorous', 'amory')); } } if (this.name) { @@ -69,27 +69,20 @@ } for (let term of this.terms || []) { + const keys = [...this.termKeys(term)]; for (let option of options) { // exact match - if (term.key && term.key.toLowerCase() === option.toLowerCase()) { - return term.key; - } - if (term.term.toLowerCase() === option.toLowerCase()) { - return term.term; - } - if (term.original && term.original.toLowerCase() === option.toLowerCase()) { - return term.original; + for (let key of keys) { + if (key.toLowerCase() === option.toLowerCase()) { + return key; + } } // fallback - if (term.key && term.key.toLowerCase().includes(option.toLowerCase())) { - fallback = term.key; - } - if (term.term.toLowerCase().includes(option.toLowerCase())) { - fallback = term.term; - } - if (term.original && term.original.toLowerCase().includes(option.toLowerCase())) { - fallback = term.original; + for (let key of keys) { + if (key.toLowerCase().includes(option.toLowerCase())) { + fallback = key; + } } } } @@ -97,6 +90,23 @@ return fallback; }, }, + methods: { + *termKeys(term) { + if (term.key) { + yield term.key; + } + if (term.term) { + for (let p of term.term.split('|')) { + yield p; + } + } + if (term.original) { + for (let p of term.original.split('|')) { + yield p; + } + } + } + } }