anvil/striker-ui/lib/getQueryParam.ts
2023-02-14 22:42:50 -05:00

14 lines
365 B
TypeScript

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;