Skip to content

Commit

Permalink
Fixes #36966 - broken link in Register Host documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga authored and ofedoren committed Dec 7, 2023
1 parent 3980566 commit be98675
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion webpack/assets/javascripts/react_app/common/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const getWikiURL = section => foremanUrl(`/links/wiki/${section}`);
*/
export const getDocsURL = (guide, chapter = null) => {
const url = foremanUrl(`/links/docs/${guide}`);
return chapter ? `{url}?chapter={encodeURIComponent(chapter)}` : url;
return chapter ? `${url}?chapter=${encodeURIComponent(chapter)}` : url;
};

/**
Expand Down
18 changes: 18 additions & 0 deletions webpack/assets/javascripts/react_app/common/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
stringIsPositiveNumber,
formatDate,
formatDateTime,
getDocsURL,
} from './helpers';

describe('isoCompatibleDate', () => {
Expand Down Expand Up @@ -130,3 +131,20 @@ describe('formatDateTime', () => {
expect(formatDateTime(date)).toEqual('2020-03-06 14:00:00');
});
});

describe('getDocsURL', () => {
it('should return URL with guide and chapter', () => {
const guide = 'Managing_Hosts';
const chapter = 'registering-a-host_managing-hosts';
const expectedUrl = '/links/docs/Managing_Hosts?chapter=registering-a-host_managing-hosts';

expect(getDocsURL(guide, chapter)).toEqual(expectedUrl);
});

it('should return URL with guide only when chapter is not provided', () => {
const guide = 'Managing_Hosts';
const expectedUrl = '/links/docs/Managing_Hosts';

expect(getDocsURL(guide)).toEqual(expectedUrl);
});
});

0 comments on commit be98675

Please sign in to comment.