summaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-06-29 19:18:32 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-06-29 19:18:32 +0200
commitcc70ec9cb09172167e7ed334b2ab1def391c6d59 (patch)
tree35bbf48e5c35d2c20939ba0ce1db7a54bd25185e /routes
parent3b85a88b54fa0b71575a297435f39122571d2c37 (diff)
downloadcollection-json-explorer-cc70ec9cb09172167e7ed334b2ab1def391c6d59.tar.gz
collection-json-explorer-cc70ec9cb09172167e7ed334b2ab1def391c6d59.tar.bz2
collection-json-explorer-cc70ec9cb09172167e7ed334b2ab1def391c6d59.tar.xz
collection-json-explorer-cc70ec9cb09172167e7ed334b2ab1def391c6d59.zip
o Adding links.
Diffstat (limited to 'routes')
-rw-r--r--routes/index.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/routes/index.js b/routes/index.js
index 0bd432d..6d57023 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -25,7 +25,17 @@ exports.render = function(req, res){
else {
var parsedBody = JSON.parse(body);
var doc = collection_json.fromObject(parsedBody);
+ var isUrl = function(u) {
+ try {
+ var x = url.parse(u);
+ return _.isString(x.protocol) && _.isString(x.host) && _.isString(path);
+ }
+ catch(e) {
+ return false;
+ }
+ };
res.render('data', {
+ isUrl: isUrl,
url: req.query.url,
doc: doc,
headers: headers,