From be6a0459a6df8827fe37167ce11bd506ec79c95b Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 31 May 2023 15:24:58 +0100 Subject: [PATCH] feat: strip trailing slash rather than complaining about it --- src/env.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/env.js b/src/env.js index f872f25..3325df2 100644 --- a/src/env.js +++ b/src/env.js @@ -23,9 +23,14 @@ const env = { ENCRYPTION_KEY: v => (!!v && v.length >= 48) || new Error('is required and must be at least 48 characters long; run "npm run keygen" to generate a key'), - HTTP_EXTERNAL: v => - (!!v && v.startsWith('http') && !v.endsWith('/')) || - new Error('must be a valid URL without a trailing slash'), + HTTP_EXTERNAL: v => { + if (v?.endsWith('/')) { + v = v.slice(0, -1); + process.env.HTTP_EXTERNAL = v; + } + return (!!v && v.startsWith('http')) || + new Error('must be a valid URL without a trailing slash'); + }, HTTP_HOST: v => (!!v && !v.startsWith('http')) || new Error('is required and must be an address, not a URL'), @@ -49,6 +54,7 @@ const load = options => { process.exit(1); } }); + console.log(process.env.HTTP_EXTERNAL); }; module.exports = {