authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-11-28 15:54:47 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-11-28 15:54:47 -08:00
log24fb8bc90898efa2f7c8fa094f9dab80d38ec55e
tree0ced07dc6b2505a5accafe4ba2cfc9fec084f447
parent5410f8ded9b0ad5379cd153cdcd7512f1db6bfd0

add trimSuffix


1 files changed, 7 insertions(+), 0 deletions(-)

src/lib.zig+7
......@@ -52,6 +52,13 @@ pub fn trimPrefix(in: string, prefix: string) string {
5252 return in;
5353}
5454
55pub fn trimSuffix(in: string, suffix: string) string {
56 if (std.mem.endsWith(u8, in, suffix)) {
57 return in[0 .. in.len - suffix.len];
58 }
59 return in;
60}
61
5562pub fn base64EncodeAlloc(alloc: std.mem.Allocator, input: string) !string {
5663 const base64 = std.base64.standard.Encoder;
5764 var buf = try alloc.alloc(u8, base64.calcSize(input.len));