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

  for (let i = 0; i < lines.length; i++) {
    let line = lines[i].trim();
    if (!line || line.startsWith("#")) continue;

    const equalsIndex = line.indexOf("=");
    if (equalsIndex === -1) {
      throw new Error(`Line ${i + 1} has no '=' character.`);
    }

    const key = line.slice(0, equalsIndex).trim();
    const value = line.slice(equalsIndex + 1).trim();

    if (!key) {
      throw new Error(`Line ${i + 1} has an empty key.`);
    }

    // Prevent prototype pollution
    if (key === "__proto__") {
      config["__proto_key"] = value;
    } else {
      config[key] = value;
    }
  }

  return config;
}
```