1. Serge Zaitsev
  2. luaeio

Commits

Serge A. Zaitsev  committed 6a7933c

the most suitable handler is picked among all registered handlers

  • Participants
  • Parent commits 7534deb
  • Branches default

Comments (0)

Files changed (1)

File eio.lua

View file
  • Ignore whitespace
 		}
 
 		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