shithub: werc

Download patch

ref: d131af2763916440a3a958cfd68c5853fa2f3b50
parent: fbb92aee3bea3d0491adbb01c7e5095fe0672cc5
author: Uriel <u@berlinblue.org>
date: Sat Aug 18 21:16:10 EDT 2012

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

--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -61,9 +61,15 @@
     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/[.,;:)]$//'}