| ... | @@ -52,6 +52,13 @@ pub fn trimPrefix(in: string, prefix: string) string { | ... | @@ -52,6 +52,13 @@ pub fn trimPrefix(in: string, prefix: string) string { |
| 52 | return in; | 52 | return in; |
| 53 | } | 53 | } |
| 54 | | 54 | |
| | 55 | pub 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 | |
| 55 | pub fn base64EncodeAlloc(alloc: std.mem.Allocator, input: string) !string { | 62 | pub fn base64EncodeAlloc(alloc: std.mem.Allocator, input: string) !string { |
| 56 | const base64 = std.base64.standard.Encoder; | 63 | const base64 = std.base64.standard.Encoder; |
| 57 | var buf = try alloc.alloc(u8, base64.calcSize(input.len)); | 64 | var buf = try alloc.alloc(u8, base64.calcSize(input.len)); |