diff --git a/striker-ui/lib/getQueryParam.ts b/striker-ui/lib/getQueryParam.ts new file mode 100644 index 00000000..7b343984 --- /dev/null +++ b/striker-ui/lib/getQueryParam.ts @@ -0,0 +1,13 @@ +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;