Commits

Anonymous committed 6a7933c

the most suitable handler is picked among all registered handlers

Comments (0)

Files changed (1)

 		}
 
 		local handler = function(r) r:write("404 Not Found\r\n") end
+		local len = 0
 		for uri, h in pairs(self.handlers) do
-			if r.uri == uri then
-				handler = h
-				break
+			-- check if URI starts with handler URI
+			if r.uri:sub(1, uri:len()) == uri then
+				if uri:len() > len then
+					handler = h
+					len = uri:len()
+				end
 			end
 		end