Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1268 from pascaloliv/QWANT-2491-burger-menu
Browse files Browse the repository at this point in the history
QMAPS-2491 - Hide burger menu with config clientRule
  • Loading branch information
pascaloliv authored Feb 15, 2022
2 parents 1137b41 + 4f168b9 commit a6c735d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions bin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion config/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a6c735d

Please sign in to comment.