summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-08-11 14:12:01 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-02 20:25:30 -0400
commitb90dea0e6dd9e8321ca616f256d8d88fb3c599d1 (patch)
tree1991e81f018f84919b09f48ed414fc40ca950d8a
parentfc4a9614123732688cad643117abf2a047593b43 (diff)
Use string.substr instead of string.split
-rw-r--r--ext/bg/js/translator.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index e9e388f3..c89b43ff 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -299,7 +299,7 @@ class Translator {
async expandTags(names, title) {
const tags = [];
for (const name of names) {
- const base = name.split(':')[0];
+ const base = Translator.getNameBase(name);
const meta = await this.database.findTagForTitle(base, title);
const tag = {name};
@@ -318,7 +318,7 @@ class Translator {
async expandStats(items, title) {
const stats = {};
for (const name in items) {
- const base = name.split(':')[0];
+ const base = Translator.getNameBase(name);
const meta = await this.database.findTagForTitle(base, title);
const group = stats[meta.category] = stats[meta.category] || [];
@@ -346,4 +346,9 @@ class Translator {
return stats;
}
+
+ static getNameBase(name) {
+ const pos = name.indexOf(':');
+ return (pos >= 0 ? name.substr(0, pos) : name);
+ }
}