fix(commands): substitute parsing bug
There was a bug in the parsing logic that caused a substitution command like `s/typo/correction` to crash the bot. Correct command is of course `s/typo/correction/`, but now it at least shouldn't crash.
This commit is contained in:
parent
4e11cc9ea1
commit
8b15398196
2 changed files with 33 additions and 12 deletions
|
|
@ -61,9 +61,11 @@ pub const Parser = struct {
|
|||
//
|
||||
// Returns a new parser window that starts after idx and the
|
||||
// extracted byte slice.
|
||||
pub fn take_until_char(self: *const Parser, c: u8) struct { Parser, []const u8 } {
|
||||
const idx = std.mem.indexOfScalar(u8, self.rest, c) orelse unreachable;
|
||||
return .{ self.seek(idx), self.rest[0..idx] };
|
||||
pub fn take_until_char(self: *const Parser, c: u8) ?struct { Parser, []const u8 } {
|
||||
if (std.mem.indexOfScalar(u8, self.rest, c)) |idx| {
|
||||
return .{ self.seek(idx), self.rest[0..idx] };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Take the current character and advance the parser one step.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue