}
// Extract the host variable
if (matcher.matches() && contains(accept) && hostMatches) {
// 404
if (action.equals("404")) {
throw new NotFound(method, path);
}
// Static dir
if (staticDir != null) {
String resource = null;
if (!staticFile) {
resource = matcher.group("resource");
}
try {
String root = new File(staticDir).getCanonicalPath();
String urlDecodedResource = Utils.urlDecodePath(resource);
String childResourceName = staticDir + (staticFile ? "" : "/" + urlDecodedResource);
String child = new File(childResourceName).getCanonicalPath();
if (child.startsWith(root)) {
throw new RenderStatic(childResourceName);
}
} catch (IOException e) {
}
throw new NotFound(resource);
} else {
Map<String, String> localArgs = new HashMap<String, String>();
for (Arg arg : args) {
// FIXME: Careful with the arguments that are not matching as they are part of the hostname
// Defaultvalue indicates it is a one of these urls. This is a trick and should be changed.