/**
 * Parses a query-string into an object.
 */
export function toQueryObject<T>(queryString: string) {
  let item;
  const parts = queryString.substring(1).split('&');
  const result = {};
  for (const i in parts) {
    if (parts[i] === '') {
      continue;
    }
    item = parts[i].split('=');
    result[decodeURIComponent(item[0])] = decodeURIComponent(item[1]);
  }
  return result as T;
}
