(search = window.location.search)
| 1 | import axios from 'axios' |
| 2 | |
| 3 | export const queryParse = (search = window.location.search) => { |
| 4 | if (!search) return {} |
| 5 | const queryString = search[0] === '?' ? search.substring(1) : search |
| 6 | const query = {} |
| 7 | queryString |
| 8 | .split('&') |
| 9 | .forEach(queryStr => { |
| 10 | const [key, value] = queryStr.split('=') |
| 11 | /* istanbul ignore else */ |
| 12 | if (key) query[decodeURIComponent(key)] = decodeURIComponent(value) |
| 13 | }) |
| 14 | |
| 15 | return query |
| 16 | } |
| 17 | |
| 18 | export const queryStringify = query => { |
| 19 | const queryString = Object.keys(query) |
no outgoing calls
no test coverage detected