From 4f168b9e36f49514dd6d8c21e2675df92378dc7d Mon Sep 17 00:00:00 2001 From: Olivier PASCAL Date: Mon, 14 Feb 2022 17:40:37 +0100 Subject: [PATCH] QMAPS-2491 - Switch burger visibility from userAgent to query parameter rule --- bin/app.js | 7 ++++--- config/default_config.yml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/app.js b/bin/app.js index 7d3f522a6..ee855d292 100644 --- a/bin/app.js +++ b/bin/app.js @@ -122,11 +122,12 @@ function App(config) { const ogMeta = new require('./middlewares/og_meta')(config); router.get('/*', redirectUnsupported, fullTextQuery, preFetchPoi, ogMeta, (req, res) => { - const userAgent = req.headers['user-agent']; - const disableMenuRule = config.server.disableBurgerMenu.userAgentRule; + const disableMenuRule = config.server.disableBurgerMenu.clientRule; const { server: _droppedServerConfig, ...appConfig } = config; + const regexpRule = new RegExp(`[?&]client=${disableMenuRule}`); + let localAppConfig = appConfig; - if (disableMenuRule && userAgent && userAgent.match(disableMenuRule)) { + if (disableMenuRule && regexpRule.test(req.originalUrl)) { localAppConfig = { ...appConfig, burgerMenu: { diff --git a/config/default_config.yml b/config/default_config.yml index 7b1fe8b17..4062faa64 100644 --- a/config/default_config.yml +++ b/config/default_config.yml @@ -15,7 +15,7 @@ server: logger: headersWhitelistEnabled: true disableBurgerMenu: - userAgentRule: '' # regex, ignored if empty + clientRule: override_by_environment # NB: `routerBaseUrl` may be different from `system.baseUrl` if a proxy is responsible for rewriting URLs routerBaseUrl: / # path prefix expected by the express server useGeoipForInitialPosition: true