You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
526 B
18 lines
526 B
import { parse, stringify } from 'query-string'; |
|
import { encode, decode } from 'js-base64'; |
|
const parseConfig = { |
|
skipNull: true, |
|
skipEmptyString: true, |
|
parseNumbers: false, |
|
parseBooleans: false, |
|
}; |
|
export function encodeParams(params = {}) { |
|
return encode(stringify(params, parseConfig)); |
|
} |
|
export function decodeParams(string = '') { |
|
return parse(decode(string), parseConfig); |
|
} |
|
const NAME = 'qSearch'; |
|
export function urlEncodeParams(params) { |
|
return '?' + NAME + '=' + encodeParams(params); |
|
}
|
|
|