```file:utils.ts
function decodeComponent(str: string): string {
  const replaced = str.replace(/\+/g, ' ');
  try {
    return decodeURIComponent(replaced);
  } catch {
    return replaced;
  }
}

export function parseQueryString(qs: string): Record<string, string | string[]> {
  const result: Record<string, string | string[]> = {};

  let input = qs;
  if (input.startsWith('?')) {
    input = input.slice(1);
  }

  if (input === '') {
    return result;
  }

  const pairs = input.split('&');

  for (const pair of pairs) {
    if (pair === '') {
      continue;
    }

    const eqIndex = pair.indexOf('=');
    let rawKey: string;
    let rawValue: string;

    if (eqIndex === -1) {
      rawKey = pair;
      rawValue = '';
    } else {
      rawKey = pair.slice(0, eqIndex);
      rawValue = pair.slice(eqIndex + 1);
    }

    const key = decodeComponent(rawKey);
    const value = decodeComponent(rawValue);

    if (Object.prototype.hasOwnProperty.call(result, key)) {
      const existing = result[key];
      if (Array.isArray(existing)) {
        existing.push(value);
      } else {
        result[key] = [existing, value];
      }
    } else {
      result[key] = value;
    }
  }

  return result;
}
```