Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 49585 invoked from network); 24 Jun 2010 09:25:24 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 Jun 2010 09:25:24 -0000 Received: (qmail 47060 invoked by uid 500); 24 Jun 2010 09:25:23 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 46933 invoked by uid 500); 24 Jun 2010 09:25:22 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 46926 invoked by uid 99); 24 Jun 2010 09:25:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jun 2010 09:25:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jun 2010 09:25:20 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BF9D223889DD; Thu, 24 Jun 2010 09:24:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r957467 - in /couchdb/branches/0.11.x: share/www/script/test/rewrite.js src/couchdb/couch_httpd_rewrite.erl Date: Thu, 24 Jun 2010 09:24:28 -0000 To: commits@couchdb.apache.org From: benoitc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100624092428.BF9D223889DD@eris.apache.org> Author: benoitc Date: Thu Jun 24 09:24:28 2010 New Revision: 957467 URL: http://svn.apache.org/viewvc?rev=957467&view=rev Log: fix #COUCHDB-787 . thanks! Modified: couchdb/branches/0.11.x/share/www/script/test/rewrite.js couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl Modified: couchdb/branches/0.11.x/share/www/script/test/rewrite.js URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/test/rewrite.js?rev=957467&r1=957466&r2=957467&view=diff ============================================================================== --- couchdb/branches/0.11.x/share/www/script/test/rewrite.js (original) +++ couchdb/branches/0.11.x/share/www/script/test/rewrite.js Thu Jun 24 09:24:28 2010 @@ -137,6 +137,13 @@ couchTests.rewrite = function(debug) { "query": { "key": [":a", ":b"] } + }, + { + "from": "simpleForm/complexView6", + "to": "_list/simpleForm/complexView3", + "query": { + "key": [":a", ":b"] + } } ], lists: { @@ -331,6 +338,10 @@ couchTests.rewrite = function(debug) { T(xhr.status == 200, "with query params"); T(/Value: doc 4/.test(xhr.responseText)); + 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)); + // test path relative to server designDoc.rewrites.push({ "from": "uuids", Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl?rev=957467&r1=957466&r2=957467&view=diff ============================================================================== --- couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl (original) +++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl Thu Jun 24 09:24:28 2010 @@ -118,6 +118,7 @@ handle_rewrite_req(#httpd{ DesignId = <<"_design/", DesignName/binary>>, Prefix = <<"/", DbName/binary, "/", DesignId/binary>>, QueryList = couch_httpd:qs(Req), + QueryList1 = [{to_atom(K), V} || {K, V} <- QueryList], #doc{body={Props}} = DDoc, @@ -132,7 +133,7 @@ handle_rewrite_req(#httpd{ %% get raw path by matching url to a rule. RawPath = case try_bind_path(DispatchList, Method, PathParts, - QueryList) of + QueryList1) of no_dispatch_path -> throw(not_found); {NewPathParts, Bindings} -> @@ -146,7 +147,7 @@ handle_rewrite_req(#httpd{ [] -> []; _ -> [$?, encode_query(Bindings)] end), - + % if path is relative detect it and rewrite path case mochiweb_util:safe_relative_path(Path) of undefined -> @@ -199,7 +200,7 @@ try_bind_path([Dispatch|Rest], Method, P % we parse query args from the rule and fill % it eventually with bindings vars QueryArgs1 = make_query_list(QueryArgs, Bindings1, []), - + % remove params in QueryLists1 that are already in % QueryArgs1 Bindings2 = lists:foldl(fun({K, V}, Acc) -> @@ -247,8 +248,13 @@ replace_var(Key, Value, Bindings) -> Value1 = lists:foldr(fun(V, Acc) -> V1 = case V of <<":", VName/binary>> -> - get_var(VName, Bindings, V); + case get_var(VName, Bindings, V) of + V2 when is_list(V2) -> + iolist_to_binary(V2); + V2 -> V2 + end; _ -> + V end, [V1|Acc]