Be a bit more careful before we redirect to plain files when we get a trailing / and can't find a dir.

This commit is contained in:
Uriel 2012-08-19 01:16:10 +02:00
parent 131d63f0f0
commit 3b1be16a19

View File

@ -61,9 +61,15 @@ fn werc_exec_request {
if(~ $local_path */) {
if(test -d $local_path)
local_path=$local_path^'index'
# If path has a trailing /, and a plain file exists matching that 'name.*'
# remove the traling / and redirect to 'name' .
# XXX: This redir might step on apps with synthetic dirs.
if not if(ls `{basename -d $local_path}^* >/dev/null >[2]/dev/null)
perm_redirect `{echo $req_path|sed 's,/+$,,'}
if not {
# TODO: Maybe we should be smarter about how to check for existing files
if(ls `{basename -d $local_path}^'.*' >/dev/null >[2]/dev/null)
perm_redirect `{echo $req_path|sed 's,/+$,,'}
}
}
if not if(~ $req_path *'.' *',' *';' *':')
perm_redirect `{echo $req_path | sed 's/[.,;:)]$//'}