Fix environment variable merging to allow empty string values

This commit is contained in:
Kenji Fujita 2026-04-15 09:55:52 +09:00
parent 0a9ab05468
commit 69165cd19b
No known key found for this signature in database
GPG key ID: E17727841CACB7A5
2 changed files with 14 additions and 1 deletions

View file

@ -0,0 +1,13 @@
import { describe, it } from "node:test";
import assert from "node:assert";
import { mergeSafeChainProxyEnvironmentVariables } from "./registryProxy.js";
describe("registryProxy.environmentVariables", () => {
it("should copy environment variables with empty string values", () => {
const envVars = mergeSafeChainProxyEnvironmentVariables({
EMPTY_VAR: "",
});
assert.strictEqual(envVars.EMPTY_VAR, "");
});
});

View file

@ -66,7 +66,7 @@ export function mergeSafeChainProxyEnvironmentVariables(env) {
// So we only copy the variable if it's not already set in a different case
const upperKey = key.toUpperCase();
if (!proxyEnv[upperKey] && env[key]) {
if (!(upperKey in proxyEnv) && env[key] !== undefined) {
proxyEnv[key] = env[key];
}
}