diff options
author | Shin'ya UEOKA <ueokande@i-beam.org> | 2018-08-07 22:01:51 +0000 |
---|---|---|
committer | Shin'ya UEOKA <ueokande@i-beam.org> | 2018-08-07 22:01:51 +0000 |
commit | 784a0d4037b781ced23435a0c1301ed7adbac5fc (patch) | |
tree | 94ef40fba75f7786129f6942e5e5b44e962d504e /src/background/controllers | |
parent | b48c2f7804cbb43ac6cd797697292ae54313f89d (diff) |
Replace trimStart
Diffstat (limited to 'src/background/controllers')
-rw-r--r-- | src/background/controllers/command.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/background/controllers/command.js b/src/background/controllers/command.js index befab42..9ab1054 100644 --- a/src/background/controllers/command.js +++ b/src/background/controllers/command.js @@ -2,6 +2,11 @@ import CompletionsInteractor from '../usecases/completions'; import CommandInteractor from '../usecases/command'; import Completions from '../domains/completions'; +const trimStart = (str) => { + // NOTE String.trimStart is available on Firefox 61 + return str.replace(/^\s+/, ''); +}; + export default class CommandController { constructor() { this.completionsInteractor = new CompletionsInteractor(); @@ -9,13 +14,13 @@ export default class CommandController { } getCompletions(line) { - let trimmed = line.trimStart(); + let trimmed = trimStart(line); let words = trimmed.split(/ +/); let name = words[0]; if (words.length === 1) { return this.completionsInteractor.queryConsoleCommand(name); } - let keywords = trimmed.slice(name.length).trimStart(); + let keywords = trimStart(trimmed.slice(name.length)); switch (words[0]) { case 'o': case 'open': @@ -45,14 +50,14 @@ export default class CommandController { // eslint-disable-next-line complexity exec(line) { - let trimmed = line.trimStart(); + let trimmed = trimStart(line); let words = trimmed.split(/ +/); let name = words[0]; if (words[0].length === 0) { return Promise.resolve(); } - let keywords = trimmed.slice(name.length).trimStart(); + let keywords = trimStart(trimmed.slice(name.length)); switch (words[0]) { case 'o': case 'open': |