| ... | ... | @@ -19,6 +19,19 @@ pub fn parse(alloc: std.mem.Allocator, cookie_str: ?string) !Jar { |
| 19 | 19 | return map; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | pub fn get(cookie_str: ?string, name: string) ?string { |
| 23 | const h = cookie_str orelse return null; |
| 24 | var iter = std.mem.split(u8, h, "; "); |
| 25 | while (iter.next()) |item| { |
| 26 | const i = std.mem.indexOfScalar(u8, item, '='); |
| 27 | if (i == null) continue; |
| 28 | const k = item[0..i.?]; |
| 29 | const v = item[i.? + 1 ..]; |
| 30 | if (std.mem.eql(u8, k, name)) return v; |
| 31 | } |
| 32 | return null; |
| 33 | } |
| 34 | |
| 22 | 35 | pub fn delete_string(comptime name: string) string { |
| 23 | 36 | return name ++ "=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT"; |
| 24 | 37 | } |