diff options
Diffstat (limited to 'routes')
-rw-r--r-- | routes/index.js | 10 |
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, |