Commit cd88d1b

NgoQuocViet2001  ·  2026-08-14 07:24:18 -0400 EDT
parent bea5fe3
fix: allow global session wildcards
1 files changed,  +14, -1
+14, -1
 1@@ -59,7 +59,11 @@ pub const SessionMatch = struct {
 2 
 3 pub fn parseSessionArg(alloc: std.mem.Allocator, raw: []const u8) !SessionMatch {
 4     if (raw.len > 0 and raw[raw.len - 1] == '*') {
 5-        const name = try getSeshName(alloc, raw[0 .. raw.len - 1]);
 6+        const prefix = raw[0 .. raw.len - 1];
 7+        const name = if (prefix.len == 0 and getSeshPrefix().len == 0)
 8+            try alloc.dupe(u8, "")
 9+        else
10+            try getSeshName(alloc, prefix);
11         return .{ .name = name, .is_prefix = true };
12     }
13     const name = try getSeshName(alloc, raw);
14@@ -228,3 +232,12 @@ test "getSocketPath boundary: name fills exactly to limit" {
15 
16     try std.testing.expectError(error.NameTooLong, getSocketPath(alloc, dir, name_over_limit));
17 }
18+
19+test "parseSessionArg accepts a wildcard matching all sessions" {
20+    const match = try parseSessionArg(std.testing.allocator, "*");
21+    defer std.testing.allocator.free(match.name);
22+
23+    try std.testing.expect(match.is_prefix);
24+    try std.testing.expectEqualStrings("", match.name);
25+    try std.testing.expect(match.matches("any-session"));
26+}