I made a change to requested_path recently on master and 1.2 but didn't get much feedback about it. It seemed like it was obviously broken to me but maybe I misunderstood the intention. Is it working the way you expect?
Relevant commit: 879a1bc19b145e126b9386aed2023f9cd1df8b31 On Wed, Feb 29, 2012 at 03:09, <[email protected]> wrote: > Testing requested_path for various combinations of rewrites and vhost > > Three test that show the requested_path in various conditions: > > 1. Accessing a show with no vhost > 2. Access the show with a vhost that contains a path > 3. Access the show with a vhost with no path > > > Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo > Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/1451ee57 > Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/1451ee57 > Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/1451ee57 > > Branch: refs/heads/COUCHDB-1416 > Commit: 1451ee57f2afdade5b24c3fb4ae37efadf9ef1ed > Parents: 766d461 > Author: Ryan Ramage <[email protected]> > Authored: Wed Feb 22 10:38:21 2012 -0700 > Committer: Jason Smith (air) <[email protected]> > Committed: Wed Feb 29 03:34:51 2012 +0000 > > ---------------------------------------------------------------------- > share/www/script/test/rewrite.js | 56 +++++++++++++++++++++++++++++++++ > 1 files changed, 56 insertions(+), 0 deletions(-) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/couchdb/blob/1451ee57/share/www/script/test/rewrite.js > ---------------------------------------------------------------------- > diff --git a/share/www/script/test/rewrite.js > b/share/www/script/test/rewrite.js > index 8454292..5b8c74f 100644 > --- a/share/www/script/test/rewrite.js > +++ b/share/www/script/test/rewrite.js > @@ -437,4 +437,60 @@ couchTests.rewrite = function(debug) { > var res = CouchDB.request("GET", > "/test_suite_db/_design/invalid/_rewrite/foo"); > TEquals(400, res.status, "should return 400"); > > + // test req.requested_path with rewrites with some vhosts > + var rw_ddoc = { > + _id: "_design/rwtest", > + rewrites: [ > + {"from":"testShow","to":"_show/show_requested_path"} > + ], > + shows : { > + show_requested_path : stringFun(function(doc, req){ > + return '/' + req.requested_path.join('/'); > + }) > + } > + } > + db.save(rw_ddoc); > + > + // try accessing directly > + var res = CouchDB.request("GET", > "/test_suite_db/_design/rwtest/_rewrite/testShow"); > + TEquals('/test_suite_db/_design/rwtest/_rewrite/testShow', > res.responseText, "requested_path should equal requested"); > + > + var host = 'localhost:5984'; > + if (window) host = window.location.host; > + > + // test a vhost with a path as well > + run_on_modified_server( > + [{section: "vhosts", > + key: encodeURIComponent(host + '/path'), > + value: "/test_suite_db/_design/rwtest/_rewrite/"} > + ], > + function(){ > + var res = CouchDB.request("GET", "/path/testShow"); > + TEquals('/path/testShow', res.responseText, "requested_path should > equal requested"); > + } > + ); > + > + // test a vhost on the root of the host > + rw_ddoc.rewrites.push({"from":"_config/*","to":"../../../_config/*"}); > + T(db.save(rw_ddoc).ok); > + run_on_modified_server( > + [{section: "httpd", > + key: "secure_rewrites", > + value: "false"} > + ], > + function(){ > + // we have to 'double wrap' with a run_on_modified_server > + // so that vhosts gets remove first, then the secure_rewrite > + run_on_modified_server( > + [{section: "vhosts", > + key: encodeURIComponent(host), > + value: "/test_suite_db/_design/rwtest/_rewrite/"} > + ], > + function() { > + var res = CouchDB.request("GET", "/testShow"); > + TEquals('/testShow', res.responseText, "requested_path > should equal requested"); > + } > + ); > + } > + ); > } >
