diff options
author | John Christopher Anderson <jchris@apache.org> | 2009-12-06 22:47:05 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2009-12-06 22:47:05 +0000 |
commit | f94630fd4af5656b4412ca5de0fc1211d19ddbf3 (patch) | |
tree | 998a65ca87e0cb3afa279d48e5466e05fa9c5a49 /share/server | |
parent | 60a6b3e7ffa209da31d563beae33726412318957 (diff) |
fix COUCHDB-593, thanks Roger Binns for reporting
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@887791 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/server')
-rw-r--r-- | share/server/render.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/share/server/render.js b/share/server/render.js index 82ceb3ab..f147af89 100644 --- a/share/server/render.js +++ b/share/server/render.js @@ -197,6 +197,21 @@ function resetProvides() { responseContentType = null; }; +// from http://javascript.crockford.com/remedial.html +function typeOf(value) { + var s = typeof value; + if (s === 'object') { + if (value) { + if (value instanceof Array) { + s = 'array'; + } + } else { + s = 'null'; + } + } + return s; +}; + function runShow(showFun, doc, req, funSrc) { try { resetProvides(); @@ -206,8 +221,9 @@ function runShow(showFun, doc, req, funSrc) { resp = runProvides(req); resp = applyContentType(maybeWrapResponse(resp), responseContentType); } - - if (resp) { + + var type = typeOf(resp); + if (type == 'object' || type == 'string') { respond(["resp", maybeWrapResponse(resp)]); } else { renderError("undefined response from show function"); |