summaryrefslogtreecommitdiff
path: root/share/www/script/test
diff options
context:
space:
mode:
authorBenoit Chesneau <benoitc@apache.org>2010-08-04 20:11:53 +0000
committerBenoit Chesneau <benoitc@apache.org>2010-08-04 20:11:53 +0000
commit635b493da67ef88af21174a4110b4d53aa4a813f (patch)
treeac8728807ab034d0de0a7ec576de0b9a0d5d473e /share/www/script/test
parent77962e9b1458e97aa8a534fe18f2eda1965cc8b1 (diff)
add wildcard support in query args so it's now possible to have rules
like : { "from": "/welcome4/*", "to" : "_show/welcome3", "query": { "name": "*" } } rewriting "_rewrite/welcome4/test" to "_show/welcome3?name=test" or { "from": "/welcome5/*", "to" : "_show/*", } rewriting "_rewrite/welcome5/welcome3" to "_show/welcome3" git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@982388 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/test')
-rw-r--r--share/www/script/test/rewrite.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/share/www/script/test/rewrite.js b/share/www/script/test/rewrite.js
index 66b33d74..56d0c31b 100644
--- a/share/www/script/test/rewrite.js
+++ b/share/www/script/test/rewrite.js
@@ -84,6 +84,20 @@ couchTests.rewrite = function(debug) {
"method": "GET"
},
{
+ "from": "/welcome4/*",
+ "to" : "_show/welcome3",
+ "query": {
+ "name": "*"
+ }
+ },
+ {
+ "from": "/welcome5/*",
+ "to" : "_show/*",
+ "query": {
+ "name": "*"
+ }
+ },
+ {
"from": "simpleForm/basicView",
"to": "_list/simpleForm/basicView",
},
@@ -169,6 +183,9 @@ couchTests.rewrite = function(debug) {
"welcome2": stringFun(function(doc, req) {
return "Welcome " + doc.name;
}),
+ "welcome3": stringFun(function(doc,req) {
+ return "Welcome " + req.query["name"];
+ })
},
updates: {
"hello" : stringFun(function(doc, req) {
@@ -288,6 +305,12 @@ couchTests.rewrite = function(debug) {
xhr = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/welcome3/test");
T(xhr.responseText == "Welcome test");
+
+ req = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/welcome4/user");
+ T(req.responseText == "Welcome user");
+
+ req = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/welcome5/welcome3");
+ T(req.responseText == "Welcome welcome3");
// get with query params
@@ -368,4 +391,4 @@ couchTests.rewrite = function(debug) {
});
-} \ No newline at end of file
+}