Skip to content

Commit 0c503e7

Browse files
Fix issues with trailing spaces in commands (#1503)
1 parent 7151f07 commit 0c503e7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/shared/services/commandInterpreterHelper.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,10 @@ const availableCommands = [
624624
name: 'history',
625625
match: (cmd: any) => /^history(\s+clear)?/.test(cmd),
626626
exec(action: any, put: any, store: any) {
627-
const match = action.cmd.match(/^:history(\s+clear)?/)
627+
const match = action.cmd
628+
.trim()
629+
.toLowerCase()
630+
.match(/^:history(\s+clear)?/)
628631
if (match[0] !== match.input) {
629632
return put(
630633
frames.add({
@@ -869,10 +872,10 @@ ${param}`)
869872
]
870873

871874
// First to match wins
872-
const interpret = (cmd: any) => {
875+
const interpret = (cmd: string) => {
873876
return availableCommands.reduce((match: any, candidate) => {
874877
if (match) return match
875-
const isMatch = candidate.match(cmd.toLowerCase())
878+
const isMatch = candidate.match(cmd.toLowerCase().trim())
876879
return isMatch ? candidate : null
877880
}, null)
878881
}

0 commit comments

Comments
 (0)