);
});
-it('should redirect to static doc for latest version', async () => {
- renderDocumentationRedirect('land', '10.0-SNAPSHOT');
-
- expect(await screen.findByRole('link')).toHaveAttribute(
- 'href',
- 'https://docs.sonarsource.com/sonarqube/latest/land',
- );
-});
-
function renderDocumentationRedirect(navigate: string, version?: string) {
renderAppRoutes(
`documentation/${navigate}`,
// This is only meant to be used directly for DocumentationRedirect. For all other uses,
// please use useDocUrl instead (it forces the use of a catalogued documentation link)
export function useUncataloguedDocUrl(to?: string) {
- const { version, documentationUrl: docUrl } = React.useContext(AppStateContext);
+ const { documentationUrl: docUrl } = React.useContext(AppStateContext);
const formatDocUrl = React.useCallback(
(href: string) => {
- const isSnapshot = version.indexOf('SNAPSHOT') !== -1;
-
const path = href.replace(/^\//, '');
- return isSnapshot
- ? `${docUrl.replace(docUrl.slice(docUrl.lastIndexOf('/')), '/latest')}/${path}`
- : `${docUrl}/${path}`;
+ return `${docUrl}/${path}`;
},
- [docUrl, version],
+ [docUrl],
);
return to ? formatDocUrl(to) : formatDocUrl;