```ts
/** The KEY=VALUE pairs of a config file. */
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    if (!line.trim()) continue; // Ignore empty lines

    const [key, value] = line.match(/^(\S+)\s*=\s*(.*)$/)?.slice(1);
    if (!key || !value) throw new Error(`Invalid config format at line: ${line}`);

    key = key.trim().toLowerCase();
    value = value.trim();

    // Prevent prototype pollution
    if (key === "__proto__") continue;

    config[key] = value;
  }
  return config;
}
```