From 0f2dc426c93787162a3a511cc7364d9fe9662b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Thu, 16 Jan 2025 09:29:37 +0100 Subject: [PATCH] Always provide a default URL to the manual via useManualURL hook This ensures tests aren't failing just because useManualURL got introduced into the component tree. --- src/web/hooks/useManualURL.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/web/hooks/useManualURL.js b/src/web/hooks/useManualURL.js index 8e81be2f52..f5648f5ec6 100644 --- a/src/web/hooks/useManualURL.js +++ b/src/web/hooks/useManualURL.js @@ -3,6 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +import {DEFAULT_MANUAL_URL} from 'gmp/gmpsettings'; import {isDefined} from 'gmp/utils/identity'; import useGmp from './useGmp'; @@ -28,13 +29,18 @@ const getLanguagePath = (locale, languageMapping) => { const useManualURL = locale => { const [userLocale] = useLocale(); const gmp = useGmp(); - const {manualUrl, manualLanguageMapping = DEFAULT_LANGUAGE_MAPPING} = - gmp.settings; - - const baseUrl = manualUrl.endsWith('/') ? manualUrl : `${manualUrl}/` - const languagePath = getLanguagePath(locale ||userLocale, manualLanguageMapping) - - return `${baseUrl}${languagePath}` + const { + manualUrl = DEFAULT_MANUAL_URL, + manualLanguageMapping = DEFAULT_LANGUAGE_MAPPING, + } = gmp.settings; + + const baseUrl = manualUrl.endsWith('/') ? manualUrl : `${manualUrl}/`; + const languagePath = getLanguagePath( + locale || userLocale, + manualLanguageMapping, + ); + + return `${baseUrl}${languagePath}`; }; export default useManualURL;