X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;ds=inline;f=modules%2Fluci-base%2Fluasrc%2Fdispatcher.lua;h=88f9440c5d7c13fef3c1dfabb807ad3d7cfb83b3;hb=7b04d0bbcf0f34393f20ccad8884a67fea9e2863;hp=c93fd78a1bf358765f4206f8491756eca646fec2;hpb=186e690c08a8766aecf9a0ffc60b4475e366d723;p=project%2Fluci.git diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua index c93fd78a1..88f9440c5 100644 --- a/modules/luci-base/luasrc/dispatcher.lua +++ b/modules/luci-base/luasrc/dispatcher.lua @@ -658,6 +658,23 @@ function node(...) return c end +function lookup(...) + local i, path = nil, {} + for i = 1, select('#', ...) do + local name, arg = nil, tostring(select(i, ...)) + for name in arg:gmatch("[^/]+") do + path[#path+1] = name + end + end + + for i = #path, 1, -1 do + local node = context.treecache[table.concat(path, ".", 1, i)] + if node and (i == #path or node.leaf) then + return node, build_url(unpack(path)) + end + end +end + function _create_node(path) if #path == 0 then return context.tree