CoastalCommitsPastes/client/lib/server/parse-url-query.ts

14 lines
356 B
TypeScript
Raw Normal View History

2022-11-09 21:38:05 -05:00
/*
* Parses a URL query string from string | string[] | ...
* to string | undefined. If it's an array, we return the last item.
*/
export function parseUrlQuery(query: string | string[] | undefined) {
if (typeof query === "string") {
return query
} else if (Array.isArray(query)) {
return query[query.length - 1]
} else {
return undefined
}
}