Skip to content

Commit

Permalink
Always provide a default URL to the manual via useManualURL hook
Browse files Browse the repository at this point in the history
This ensures tests aren't failing just because useManualURL got
introduced into the component tree.
  • Loading branch information
bjoernricks committed Jan 16, 2025
1 parent b47c1fc commit 0f2dc42
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/web/hooks/useManualURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;

0 comments on commit 0f2dc42

Please sign in to comment.