(profile)(bug) fix flags link matching

This commit is contained in:
Andrea Vos 2023-07-01 18:48:47 +02:00
parent 7a240ada4f
commit b9211b8e7b

View File

@ -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;
}
}
}
}
}
</script>