summaryrefslogtreecommitdiff
path: root/share/server
diff options
context:
space:
mode:
Diffstat (limited to 'share/server')
-rw-r--r--share/server/render.js20
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");