couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject svn commit: r987384 - in /couchdb/trunk: src/couchdb/couch_httpd_vhost.erl test/etap/160-vhosts.t
Date Fri, 20 Aug 2010 06:22:42 GMT
Author: benoitc
Date: Fri Aug 20 06:22:41 2010
New Revision: 987384

URL: http://svn.apache.org/viewvc?rev=987384&view=rev
Log:
sysadmins were shocked that we can use $ for anything else than a shell
environment variable. use ":" instead. use ":" instead like we do in
_rewrite handler. like we do in _rewrite handler.

Modified:
    couchdb/trunk/src/couchdb/couch_httpd_vhost.erl
    couchdb/trunk/test/etap/160-vhosts.t

Modified: couchdb/trunk/src/couchdb/couch_httpd_vhost.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_vhost.erl?rev=987384&r1=987383&r2=987384&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_vhost.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_vhost.erl Fri Aug 20 06:22:41 2010
@@ -63,8 +63,8 @@
 %%
 %%    [vhosts]
 %%    *.example.com = /*
-%%    $dbname.example.com = /$dbname
-%%    $ddocname.$dbname.example.com = /$dbname/_design/$ddocname/_rewrite
+%%    :dbname.example.com = /:dbname
+%%    :ddocname.:dbname.example.com = /:dbname/_design/:ddocname/_rewrite
 %%
 %% First rule pass wildcard as dbname, second do the same but use a
 %% variable name and the third one allows you to use any app with
@@ -312,14 +312,18 @@ make_vhosts() ->
 
 
 split_host_port(HostAsString) ->
-    case string:tokens(HostAsString, ":") of
-        [HostPart, PortPart] ->
-            {split_host(HostPart), list_to_integer(PortPart)};
-        [HostPart] ->
-            {split_host(HostPart), 80};
-        [] ->
-            %% no host header
-            {[], 80}
+    case string:rchr(HostAsString, $:) of
+        0 ->
+            {split_host(HostAsString), 80};
+        N ->
+            HostPart = string:substr(HostAsString, 1, N-1), 
+            case (catch erlang:list_to_integer(HostAsString, N+1,
+                        length(HostAsString))) of
+                {'EXIT', _} ->
+                    {split_host(HostAsString), 80};
+                Port ->
+                    {split_host(HostPart), Port}
+            end
     end.
 
 split_host(HostAsString) ->
@@ -342,7 +346,7 @@ make_spec([P|R], Acc) ->
 
 parse_var(P) ->
     case P of 
-        "$" ++ Var ->
+        ":" ++ Var ->
             {bind, Var};
         _ -> P
     end.

Modified: couchdb/trunk/test/etap/160-vhosts.t
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/etap/160-vhosts.t?rev=987384&r1=987383&r2=987384&view=diff
==============================================================================
--- couchdb/trunk/test/etap/160-vhosts.t (original)
+++ couchdb/trunk/test/etap/160-vhosts.t Fri Aug 20 06:22:41 2010
@@ -107,9 +107,9 @@ test() ->
             "/etap-test-db/_design/doc1/_rewrite", false),
     ok = couch_config:set("vhosts", "example1.com", 
             "/etap-test-db/_design/doc1/_rewrite/", false),
-    ok = couch_config:set("vhosts","$appname.$dbname.example1.com",
-            "/$dbname/_design/$appname/_rewrite/", false),
-    ok = couch_config:set("vhosts", "$dbname.example1.com", "/$dbname", false),
+    ok = couch_config:set("vhosts",":appname.:dbname.example1.com",
+            "/:dbname/_design/:appname/_rewrite/", false),
+    ok = couch_config:set("vhosts", ":dbname.example1.com", "/:dbname", false),
     ok = couch_config:set("vhosts", "*.example2.com", "/*", false),
 
 



Mime
View raw message