/usr/share/lua/5.1/xavante/urlhandler.lua is in xavante 2.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | -----------------------------------------------------------------------------
-- Xavante URL paths handler
--
-- Authors: Javier Guerra
-- Copyright (c) 2006-2007 Kepler Project
--
-- $Id: urlhandler.lua,v 1.3 2007/08/20 22:20:44 carregal Exp $
-----------------------------------------------------------------------------
local httpd = require "xavante.httpd"
local function path_p (s, p)
if not p then return s end
if p=="" then return nil end
return string.gsub (p, "[^/]*/?$", "")
end
local function path_iterator (path)
return path_p, path
end
local function match_url (req, conf)
local path = req.relpath
local h = nil
for p in path_iterator (path) do
h = conf [p]
if h then
req.match = p
break
end
end
if req.match then
local _,_,pfx = string.find (req.match, "^(.*/)[^/]-$")
assert (string.sub (path, 1, string.len (pfx)) == pfx)
req.relpath = string.sub (path, string.len (pfx)+1)
end
req.handler = h
end
return function (conf)
if not conf or type (conf) ~= "table" then return nil end
return function (req, res)
match_url (req, conf)
local h = req.handler or httpd.err_404
return h (req, res)
end
end
|