shithub: werc

Download patch

ref: 9e62f9b8c5f2f5e7a89a053cf4f944f846a34f38
parent: c7266dcc727e772e15aad3b91c19ecefc6a7f53c
author: uriel <[email protected]>
date: Mon Jan 5 00:41:10 EST 2009

Make perm redirect code a bit simpler and a bit less hideous.

--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -219,13 +219,13 @@
 cd $werc_root
 
 # Redirections and other preprocessing
-if(~ $#redirectPermanent 1)
+if(~ $#redirectPermanent 1) {
     perm_redirect $"redirectPermanent
-
-if not if(~ $#redirectPermanent 2 && {echo $SERVER_NAME^$req_path|grep -s $redirectPermanent(1) }) {
-    # Experimental regexp sub-based redirect, probably should find a nicer interface
-    to=`{echo $SERVER_NAME^$req_path|sed 's@'^$redirectPermanent(1)^'@'^$redirectPermanent(2)^'@'}
-    if(! ~ $to $req_path)
+}
+if not if(~ $#redirectPermanent 2) {
+    from='http://'^$SERVER_NAME^$req_path
+    to=`{echo $from|sed 's@'^$redirectPermanent(1)^'@'^$redirectPermanent(2)^'@'}
+    if(! ~ $to $from)
         perm_redirect $to
 }