diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util.js | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/util.js b/lib/util.js index d8da1e5..77b7fac 100644 --- a/lib/util.js +++ b/lib/util.js @@ -39,21 +39,21 @@ exports.heir = function heir(p) { */ var getParamsFromURL = exports.getParamsFromURL = function getParamsFromURL (url) { if (!url || (url.toString().length === 0)) { - return null; + throw new Error("Missing URL value!"); } if (!(url instanceof urlMod.URL)) { url = new urlMod.URL(url.toString()); } - if (url.path === "/") { - return null; + var paramsArr = url.path.split("?"); + if (paramsArr.length === 1) { + return {}; } - var paramsArr = url.path.split("?")[1].split('&'); // get convert URL parameters to an Object var params = {}, s = []; - paramsArr.forEach(function(par) { + paramsArr[1].split('&').forEach(function(par) { s = par.split('='); params[s[0]] = s[1]; }); @@ -61,9 +61,6 @@ var getParamsFromURL = exports.getParamsFromURL = function getParamsFromURL (url }; exports.getBugNo = function getBugNo(url) { - if (!url) { - throw new Error("Missing URL value!"); - } var params = getParamsFromURL(url); if (params && params.id) { return parseInt(params.id, 10); |