aboutsummaryrefslogtreecommitdiff
path: root/src/string_immutable.zig
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2023-06-02 20:45:48 -0700
committerGravatar GitHub <noreply@github.com> 2023-06-02 20:45:48 -0700
commit3e437a6ae0d4a68f8f29c60276918d662ad7bbc7 (patch)
tree916b36f17eda8f96482da2de42b361a202f3b215 /src/string_immutable.zig
parentd8e7436db02f38f74ce29b4a0e7c0efcd133ec53 (diff)
downloadbun-3e437a6ae0d4a68f8f29c60276918d662ad7bbc7.tar.gz
bun-3e437a6ae0d4a68f8f29c60276918d662ad7bbc7.tar.zst
bun-3e437a6ae0d4a68f8f29c60276918d662ad7bbc7.zip
check package name length in `shouldUnwrapRequire()` (#3183)
* make sure length is equal * add and use `indexEqualAny`
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r--src/string_immutable.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index 25d4fb01a..3d1724d4e 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -127,6 +127,11 @@ pub inline fn indexAnyComptime(target: string, comptime chars: string) ?usize {
return null;
}
+pub inline fn indexEqualAny(in: anytype, target: string) ?usize {
+ for (in, 0..) |str, i| if (eqlLong(str, target, true)) return i;
+ return null;
+}
+
pub fn repeatingAlloc(allocator: std.mem.Allocator, count: usize, char: u8) ![]u8 {
var buf = try allocator.alloc(u8, count);
repeatingBuf(buf, char);