()
| 1 | // http://stackoverflow.com/a/979995 |
| 2 | // Modified to use hash |
| 3 | export const getHashString = () => { |
| 4 | var params = {} |
| 5 | var hash = window.location.hash.substring(1) |
| 6 | |
| 7 | if (hash.length === 0) { |
| 8 | return params |
| 9 | } |
| 10 | |
| 11 | var vars = hash.split("&") |
| 12 | |
| 13 | for (var i = 0; i < vars.length; i++) { |
| 14 | var pair = vars[i].split("=") |
| 15 | // If first entry with this name |
| 16 | if (typeof params[pair[0]] === "undefined") { |
| 17 | params[pair[0]] = decodeURIComponent(pair[1]) |
| 18 | // If second entry with this name |
| 19 | } else if (typeof params[pair[0]] === "string") { |
| 20 | var arr = [params[pair[0]], decodeURIComponent(pair[1])] |
| 21 | params[pair[0]] = arr |
| 22 | // If third or later entry with this name |
| 23 | } else { |
| 24 | params[pair[0]].push(decodeURIComponent(pair[1])) |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | return params |
| 29 | } |
| 30 | |
| 31 | const buildHashString = (pairs = {}) => { |
| 32 | const hs = [] |
no outgoing calls
no test coverage detected