local r = {}
context.request = r
+ context.urltoken = {}
+
local pathinfo = http.urldecode(request:getenv("PATH_INFO") or "", true)
if prefix then
end
end
+ local tokensok = true
for node in pathinfo:gmatch("[^/]+") do
- r[#r+1] = node
+ local tkey, tval
+ if tokensok then
+ tkey, tval = node:match(";(%w+)=([a-fA-F0-9]*)")
+ end
+ if tkey then
+ context.urltoken[tkey] = tval
+ else
+ tokensok = false
+ r[#r+1] = node
+ end
end
local stat, err = util.coxpcall(function()
--context._disable_memtrace = require "luci.debug".trap_memtrace("l")
local ctx = context
ctx.path = request
- ctx.urltoken = ctx.urltoken or {}
local conf = require "luci.config"
assert(conf.main,
ctx.args = args
ctx.requestargs = ctx.requestargs or args
local n
- local t = true
local token = ctx.urltoken
local preq = {}
local freq = {}
for i, s in ipairs(request) do
- local tkey, tval
- if t then
- tkey, tval = s:match(";(%w+)=([a-fA-F0-9]*)")
+ preq[#preq+1] = s
+ freq[#freq+1] = s
+ c = c.nodes[s]
+ n = i
+ if not c then
+ break
end
- if tkey then
- token[tkey] = tval
- else
- t = false
- preq[#preq+1] = s
- freq[#freq+1] = s
- c = c.nodes[s]
- n = i
- if not c then
- break
- end
-
- util.update(track, c)
+ util.update(track, c)
- if c.leaf then
- break
- end
+ if c.leaf then
+ break
end
end
end
local ctx = context
- local tree = {nodes={}}
+ local tree = {nodes={}, inreq=true}
local modi = {}
ctx.treecache = setmetatable({}, {__mode="v"})
local parent = _create_node(path)
c = {nodes={}, auto=true}
+ -- the node is "in request" if the request path matches
+ -- at least up to the length of the node path
+ if parent.inreq and context.path[#path+1] == last then
+ c.inreq = true
+ end
parent.nodes[last] = c
context.treecache[name] = c
end