fix: parse MAILDEV_HTTPS as a boolean (#294)

MAILDEV_HTTPS is listed in BOOLEAN_VARS, but envVarToConfigKey() had no
entry for `https`, so the boolean pass skipped it and the raw string from
ENV_MAPPING stayed in the config. MAILDEV_HTTPS=false then enabled HTTPS
and validation demanded httpsCert and httpsKey.
This commit is contained in:
dualfroz committed 2026-10-02 15:52:08 +02:00
1 parent 7f6defcdc5
commit a10bcd3e4c
3 files changed
+31

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
---
'maildev': patch
---
Parse `MAILDEV_HTTPS` as a boolean (#294). It was passed through as the raw
string, so `MAILDEV_HTTPS=false` still enabled HTTPS and startup failed asking
for `httpsCert` and `httpsKey`.
@@ -101,6 +101,29 @@ describe('loadEnvConfig', () => {
expect(config.basePathname).toBe('/mail/')
})
it('should parse MAILDEV_HTTPS=true as boolean true', () => {
process.env.MAILDEV_HTTPS = 'true'
const config = loadEnvConfig()
expect(config.https).toBe(true)
})
it('should parse MAILDEV_HTTPS=false as boolean false', () => {
process.env.MAILDEV_HTTPS = 'false'
const config = loadEnvConfig()
expect(config.https).toBe(false)
})
it('should load MAILDEV_HTTPS_CERT and MAILDEV_HTTPS_KEY as path strings', () => {
process.env.MAILDEV_HTTPS_CERT = '/ssl/cert.pem'
process.env.MAILDEV_HTTPS_KEY = '/ssl/key.pem'
const config = loadEnvConfig()
expect(config.httpsCert).toBe('/ssl/cert.pem')
expect(config.httpsKey).toBe('/ssl/key.pem')
})
it('should ignore invalid port numbers', () => {
process.env.MAILDEV_SMTP_PORT = 'not-a-number'
+1
View File
@@ -145,6 +145,7 @@ function envVarToConfigKey(envVar: string): keyof PartialMailDevConfig | null {
webPort: 'web',
incomingSecure: 'incomingSecure',
outgoingSecure: 'outgoingSecure',
https: 'https',
disableWeb: 'disableWeb',
verbose: 'verbose',
silent: 'silent',