╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Attachment.zig ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
87 else => return null, 88 }; 89 if (!std.mem.startsWith(u8, action, prefix) or !std.mem.endsWith(u8, action, suffix)) return null; 90 const at = std.mem.lastIndexOf(u8, action, infix) orelse return null; 91 const id = action[at + infix.len .. action.len - suffix.len]; 92 if (id.len != evt.event_id_size * 2) return null; 93 var bytes: [evt.event_id_size]u8 = undefined; 94 _ = std.fmt.hexToBytes(&bytes, id) catch return null; 95 return bytes; 96 } 97 98 // the url an attachment's bytes are served from 99 pub fn url(page_arena: *std.heap.ArenaAllocator, identity: []const u8, id: []const u8) ![]const u8 { 100 return if (identity.len == 0) 101 try page_arena.allocator().print("/attachment:{s}", .{id}) 102 else 103 try page_arena.allocator().print("/{s}/attachment:{s}", .{ identity, id }); 104 } 105