1import invariant from 'invariant';
2import qs from 'qs';
3export function buildQueryString(input) {
4    return qs.stringify(input);
5}
6export function getQueryParams(url) {
7    const parts = url.split('#');
8    const hash = parts[1];
9    const partsWithoutHash = parts[0].split('?');
10    const queryString = partsWithoutHash[partsWithoutHash.length - 1];
11    // Get query string (?hello=world)
12    const parsedSearch = qs.parse(queryString, { parseArrays: false });
13    // Pull errorCode off of params
14    const errorCode = (parsedSearch.errorCode ?? null);
15    invariant(typeof errorCode === 'string' || errorCode === null, `The "errorCode" parameter must be a string if specified`);
16    delete parsedSearch.errorCode;
17    // Get hash (#abc=example)
18    let parsedHash = {};
19    if (parts[1]) {
20        parsedHash = qs.parse(hash);
21    }
22    // Merge search and hash
23    const params = {
24        ...parsedSearch,
25        ...parsedHash,
26    };
27    return {
28        errorCode,
29        params,
30    };
31}
32//# sourceMappingURL=QueryParams.js.map