Recently I got into a situation where I need in the client side the value of a specific parameter in the request’s query string and I need to be sure that I could find the parameter regardless its casing. For that purpose I crate the following function in TypeScript:

1
2
3
4
5
private getInsensitiveQueryStringValue(queryParams: Params, paramKey: string): string {
  const keys = Object.keys(queryParams);
  const key = Array.from(keys).find(item => item.toLowerCase() == paramKey.toLowerCase());
  return key ? queryParams[key] : null;
}