From 0f01fe2c07a37d5cf39069839b771735327392bc Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Mar 2026 19:01:17 -0300 Subject: [PATCH] fix(env): prevent crash on single-character .env values A value like `X=a` would pass the startsWith/endsWith quote check (both `"` and `'` are single chars), then slice(1, -1) would produce an empty string, silently dropping the value. Add length >= 2 guard before checking for surrounding quotes. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/env.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/env.ts b/src/env.ts index 988b59e..82cd5c3 100644 --- a/src/env.ts +++ b/src/env.ts @@ -30,8 +30,9 @@ export function readEnvFile(keys: string[]): Record { if (!wanted.has(key)) continue; let value = trimmed.slice(eqIdx + 1).trim(); if ( - (value.startsWith('"') && value.endsWith('"')) || - (value.startsWith("'") && value.endsWith("'")) + value.length >= 2 && + ((value.startsWith('"') && value.endsWith('"')) || + (value.startsWith("'") && value.endsWith("'"))) ) { value = value.slice(1, -1); }