Skip to content

Commit

Permalink
feat: strip trailing slash rather than complaining about it
Browse files Browse the repository at this point in the history
  • Loading branch information
eartharoid committed May 31, 2023
1 parent 10c006d commit be6a045
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/env.js
Expand Up @@ -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'),
Expand All @@ -49,6 +54,7 @@ const load = options => {
process.exit(1);
}
});
console.log(process.env.HTTP_EXTERNAL);
};

module.exports = {
Expand Down

0 comments on commit be6a045

Please sign in to comment.