Use string.substr instead of string.split
This commit is contained in:
parent
fc4a961412
commit
b90dea0e6d
@ -299,7 +299,7 @@ class Translator {
|
|||||||
async expandTags(names, title) {
|
async expandTags(names, title) {
|
||||||
const tags = [];
|
const tags = [];
|
||||||
for (const name of names) {
|
for (const name of names) {
|
||||||
const base = name.split(':')[0];
|
const base = Translator.getNameBase(name);
|
||||||
const meta = await this.database.findTagForTitle(base, title);
|
const meta = await this.database.findTagForTitle(base, title);
|
||||||
|
|
||||||
const tag = {name};
|
const tag = {name};
|
||||||
@ -318,7 +318,7 @@ class Translator {
|
|||||||
async expandStats(items, title) {
|
async expandStats(items, title) {
|
||||||
const stats = {};
|
const stats = {};
|
||||||
for (const name in items) {
|
for (const name in items) {
|
||||||
const base = name.split(':')[0];
|
const base = Translator.getNameBase(name);
|
||||||
const meta = await this.database.findTagForTitle(base, title);
|
const meta = await this.database.findTagForTitle(base, title);
|
||||||
const group = stats[meta.category] = stats[meta.category] || [];
|
const group = stats[meta.category] = stats[meta.category] || [];
|
||||||
|
|
||||||
@ -346,4 +346,9 @@ class Translator {
|
|||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getNameBase(name) {
|
||||||
|
const pos = name.indexOf(':');
|
||||||
|
return (pos >= 0 ? name.substr(0, pos) : name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user