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
......@@ -59,7 +59,11 @@ pub const SessionMatch = struct {
5959
6060 pub fn parseSessionArg(alloc: std.mem.Allocator, raw: []const u8) !SessionMatch {
6161 if (raw.len > 0 and raw[raw.len - 1] == '*') {
62- const name = try getSeshName(alloc, raw[0 .. raw.len - 1]);
62+ const prefix = raw[0 .. raw.len - 1];
63+ const name = if (prefix.len == 0 and getSeshPrefix().len == 0)
64+ try alloc.dupe(u8, "")
65+ else
66+ try getSeshName(alloc, prefix);
6367 return .{ .name = name, .is_prefix = true };
6468 }
6569 const name = try getSeshName(alloc, raw);
......@@ -228,3 +232,12 @@ test "getSocketPath boundary: name fills exactly to limit" {
228232
229233 try std.testing.expectError(error.NameTooLong, getSocketPath(alloc, dir, name_over_limit));
230234 }
235+
236+test "parseSessionArg accepts a wildcard matching all sessions" {
237+ const match = try parseSessionArg(std.testing.allocator, "*");
238+ defer std.testing.allocator.free(match.name);
239+
240+ try std.testing.expect(match.is_prefix);
241+ try std.testing.expectEqualStrings("", match.name);
242+ try std.testing.expect(match.matches("any-session"));
243+}