1const std = @import("std");
2const string = []const u8;
3const extras = @import("./lib.zig");
4
5pub fn trimSuffix(in: string, suffix: string) string {
6 if (std.mem.endsWith(u8, in, suffix)) {
7 return in[0 .. in.len - suffix.len];
8 }
9 return in;
10}
11
12test {
13 try std.testing.expect(std.mem.eql(u8, trimSuffix("abaabbaaba", "c"), "abaabbaaba"));
14}
15test {
16 try std.testing.expect(std.mem.eql(u8, trimSuffix("abaabbaaba", "aba"), "abaabba"));
17}