summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorBenoit Chesneau <benoitc@apache.org>2010-09-07 21:07:17 +0000
committerBenoit Chesneau <benoitc@apache.org>2010-09-07 21:07:17 +0000
commitc1b74df08076cd850617e500163fdb5fc8d55f3a (patch)
tree6516b641161c51ac116289468a904ae9951f798c /share
parent7d478cf34867e4c5475f907acdd9d4ef283c3db4 (diff)
improve rewriter. No< it's possible to pass a variable in path as <var>
so you can do /somepath/<var>something or /somepath/<var>.txt ... git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@993532 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share')
-rw-r--r--share/www/script/test/rewrite.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/share/www/script/test/rewrite.js b/share/www/script/test/rewrite.js
index 86905f8f..474abb5e 100644
--- a/share/www/script/test/rewrite.js
+++ b/share/www/script/test/rewrite.js
@@ -91,6 +91,27 @@ 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": {
@@ -193,6 +214,9 @@ 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: {
@@ -380,6 +404,15 @@ 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({