14 lines
365 B
TypeScript
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;
|