From 88dca3688e90dbc519b81963e12c0bb7756294e8 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Fri, 2 Sep 2011 01:32:54 -0400 Subject: [PATCH] Updated response to check if there needs to be [] added to ensure JSON validity --- ubuntuone.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ubuntuone.js b/ubuntuone.js index 2b9273f..aa346f0 100644 --- a/ubuntuone.js +++ b/ubuntuone.js @@ -102,8 +102,15 @@ http.createServer(function(request, response) value = ''; } } + + payload = payload.replace('{{', '[{').replace('}}', '}]'); - response.end(payload.replace('{{', '[{').replace('}}', '}]')); + if (payload.charAt(0) != '[') + { + payload = '[' + payload + ']'; + } + + response.end(payload + '\n'); } });