The recipe and input are now stored in the hash part of the URL

This commit is contained in:
n1474335 2017-06-16 11:04:35 +00:00
parent 61951e76ac
commit 00e7d8a390
4 changed files with 50 additions and 29 deletions

View file

@ -981,6 +981,37 @@ const Utils = {
},
/**
* Parses URI parameters into a JSON object.
*
* @param {string} paramStr - The serialised query or hash section of a URI
* @returns {object}
*
* @example
* // returns {a: 'abc', b: '123'}
* Utils.parseURIParams("?a=abc&b=123")
* Utils.parseURIParams("#a=abc&b=123")
*/
parseURIParams: function(paramStr) {
if (paramStr === "") return {};
// Cut off ? or # and split on &
const params = paramStr.substr(1).split("&");
const result = {};
for (let i = 0; i < params.length; i++) {
const param = params[i].split("=");
if (param.length !== 2) {
result[params[i]] = true;
} else {
result[param[0]] = decodeURIComponent(param[1].replace(/\+/g, " "));
}
}
return result;
},
/**
* Actual modulo function, since % is actually the remainder function in JS.
*