From fc04b7f6cdda90fc9dcb1ec01bc150fac69262d9 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Wed, 4 Jan 2023 13:05:07 +0100 Subject: [PATCH] Update base URL handling --- pug.config.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pug.config.js b/pug.config.js index 83aa4c87d50..141312ab612 100644 --- a/pug.config.js +++ b/pug.config.js @@ -2,9 +2,7 @@ const helpers = require('./helpers') const IS_DEV = process.env.NODE_ENV === 'development' -const { DEPLOY_PRIME_URL, URL } = process.env -const BASE = DEPLOY_PRIME_URL || URL || 'https://einundzwanzig.space' -const HOST = IS_DEV ? 'http://localhost:3000' : BASE +const HOST = IS_DEV ? 'http://localhost:3000' : getBaseUrl() const random = max => Math.floor(Math.random() * Math.floor(max)) const shuffle = arr => { for (let i = arr.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * i); const temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; }; return arr } const formatDate = date => (new Date(date)).toISOString().replace(/T.*/, '').split('-').reverse().join('.') @@ -22,6 +20,11 @@ const assetUrl = (path, protocol = 'https') => { if (!url.startsWith(`${protocol}:`)) url = url.replace(/^.*:/, `${protocol}:`) return url } +function getBaseUrl () { + const { DEPLOY_PRIME_URL, URL } = process.env + const branchUrl = DEPLOY_PRIME_URL || URL || '' + return !branchUrl.match('master--einundzwanzig') ? branchUrl : 'https://einundzwanzig.space' +} module.exports = { basedir: './src/includes',