This commit is contained in:
Jeeves 2024-03-26 08:33:50 -06:00
parent 459dae22b9
commit f396247079

View file

@ -227,8 +227,9 @@ pub const Listener = struct {
var node: *Node = &self.root_node; var node: *Node = &self.root_node;
var wildcard_param: ?[]const u8 = null; var wildcard_param: ?[]const u8 = null;
var remaining = mem.count(u8, path, "/") + 1;
var sections = mem.splitScalar(u8, path, '/'); var sections = mem.splitScalar(u8, path, '/');
while (sections.next()) |section| { while (sections.next()) |section| : (remaining -= 1) {
if (node.wildcard_child_node) |wildcard_child_node| { if (node.wildcard_child_node) |wildcard_child_node| {
wildcard_node = wildcard_child_node; wildcard_node = wildcard_child_node;
wildcard_param = sections.rest(); wildcard_param = sections.rest();
@ -242,6 +243,12 @@ pub const Listener = struct {
var child_node: ?*Node = null; var child_node: ?*Node = null;
if (node.placeholder_children.items.len > 1) { if (node.placeholder_children.items.len > 1) {
// TODO // TODO
for (node.placeholder_children.items) |child| place: {
if (child.max_depth == remaining) {
child_node = child;
break :place;
}
}
} else if (node.placeholder_children.items.len == 1) } else if (node.placeholder_children.items.len == 1)
child_node = node.placeholder_children.items[0]; child_node = node.placeholder_children.items[0];