anvil/striker-ui/lib/getQueryParam.ts

14 lines
365 B
TypeScript
Raw Normal View History

2023-02-10 22:37:29 +00:00
const getQueryParam = (
queryParam?: string | string[],
{
fallbackValue = '',
joinSeparator = '',
limit = 1,
}: { fallbackValue?: string; joinSeparator?: string; limit?: number } = {},
): string =>
queryParam instanceof Array
? queryParam.slice(0, limit).join(joinSeparator)
: queryParam ?? fallbackValue;
export default getQueryParam;