couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject svn commit: r1083320 - in /couchdb/trunk: share/www/script/test/rewrite.js src/couchdb/couch_httpd_rewrite.erl
Date Sat, 19 Mar 2011 22:42:08 GMT
Author: benoitc
Date: Sat Mar 19 22:42:07 2011
New Revision: 1083320

URL: http://svn.apache.org/viewvc?rev=1083320&view=rev
Log:
revert revison 993532
http://svn.apache.org/viewvc?view=revision&revision=993532

Current rewriter is limited to the design we settled sometimes ago to
reverse pattern matching. <var> introduced an exception to this design.
fix issue #COUCHDB-1094.

Modified:
    couchdb/trunk/share/www/script/test/rewrite.js
    couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl

Modified: couchdb/trunk/share/www/script/test/rewrite.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/rewrite.js?rev=1083320&r1=1083319&r2=1083320&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/rewrite.js (original)
+++ couchdb/trunk/share/www/script/test/rewrite.js Sat Mar 19 22:42:07 2011
@@ -91,27 +91,6 @@ couchTests.rewrite = function(debug) {
              }
             },
             {
-             "from": "/type/<type>.json",
-             "to": "_show/type/:type",
-             "query": {
-                 "format": "json"
-             }
-            },
-            {
-             "from": "/type/<type>.xml",
-             "to": "_show/type/:type",
-             "query": {
-                 "format": "xml"
-             }
-            },
-            {
-             "from": "/type/<type>",
-             "to": "_show/type/:type",
-             "query": {
-                 "format": "html"
-             }
-            },
-            {
              "from": "/welcome5/*",
              "to" : "_show/*",
              "query": {
@@ -214,9 +193,6 @@ couchTests.rewrite = function(debug) {
             }),
             "welcome3": stringFun(function(doc,req) {
               return "Welcome " + req.query["name"];
-            }),
-            "type": stringFun(function(doc, req) {
-                return req.id + " as " + req.query.format;
             })
           },
           updates: {
@@ -404,15 +380,6 @@ couchTests.rewrite = function(debug) {
         xhr = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/simpleForm/complexView6?a=test&b=essai");
         T(xhr.status == 200, "with query params");
         T(/Value: doc 4/.test(xhr.responseText));
-
-        req = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/type/test.json");
-        T(req.responseText == "test as json");
-
-        req = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/type/test.xml");
-        T(req.responseText == "test as xml");
-
-         req = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/type/test");
-        T(req.responseText == "test as html");
         
         // test path relative to server
         designDoc.rewrites.push({

Modified: couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl?rev=1083320&r1=1083319&r2=1083320&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl Sat Mar 19 22:42:07 2011
@@ -106,15 +106,6 @@
 %% {"from": "/a",           /a?foo=b        /some/b             foo =:= b
 %% "to": "/some/:foo",
 %%  }}
-%% 
-%% {"from": "/a/<foo>"      /a/b            /some/b             foo =:= b
-%% "to": "/a/b",
-%% }}
-%%
-%% {"from": "/a/<foo>.blah"      /a/b            /some/b        foo =:= b
-%% "to": "/a/b",
-%% }}
-
 
 
 
@@ -336,14 +327,6 @@ bind_path([?MATCH_ALL], [Match|_RestMatc
     {ok, Rest, [{?MATCH_ALL, Match}|Bindings]};
 bind_path(_, [], _) ->
     fail;
-bind_path([{bind, {Token, MatchRe}}|RestToken],
-        [Match|RestMatch],Bindings) ->
-    case re:run(Match, MatchRe, [{capture, all, binary}]) of
-        {match, [_, Match1]} ->
-            bind_path(RestToken, RestMatch, [{{bind, Token}, Match1}|Bindings]);
-        _ ->
-            fail 
-    end;
 bind_path([{bind, Token}|RestToken],[Match|RestMatch],Bindings) ->
     bind_path(RestToken, RestMatch, [{{bind, Token}, Match}|Bindings]);
 bind_path([Token|RestToken], [Token|RestMatch], Bindings) ->
@@ -421,18 +404,8 @@ path_to_list([<<"..">>|R], Acc, DotDotCo
     path_to_list(R, [<<"..">>|Acc], DotDotCount+1);
 path_to_list([P|R], Acc, DotDotCount) ->
     P1 = case P of
-        <<"<", _Rest/binary>> ->
-            {ok, VarRe} = re:compile(<<"<([^>].*)>(.*)">>),
-            case re:run(P, VarRe, [{capture, all, binary}]) of
-                {match, [_, Var, Match]} ->
-                    {ok, MatchRe} = re:compile(<<"(.*)", Match/binary>>),
-                    {bind, {Var, MatchRe}};
-                _ -> P
-            end;
         <<":", Var/binary>> ->
             to_binding(Var);
-
-
         _ -> P
     end,
     path_to_list(R, [P1|Acc], DotDotCount).



Mime
View raw message