diff --git a/scm-ui/ui-components/src/MarkdownLinkRenderer.test.tsx b/scm-ui/ui-components/src/MarkdownLinkRenderer.test.tsx
index a9cc02ddfe..7390ee0709 100644
--- a/scm-ui/ui-components/src/MarkdownLinkRenderer.test.tsx
+++ b/scm-ui/ui-components/src/MarkdownLinkRenderer.test.tsx
@@ -30,6 +30,7 @@ const pathname = basePath + "README.md/";
describe("correctLocalLink tests", () => {
it("should return same url", () => {
expect(correctLocalLink(pathname, "")).toBe(pathname);
+ expect(correctLocalLink(pathname, "#42")).toBe("#42");
});
it("should return main directory", () => {
diff --git a/scm-ui/ui-components/src/MarkdownLinkRenderer.tsx b/scm-ui/ui-components/src/MarkdownLinkRenderer.tsx
index 4c9b9ae6ab..1c4c26020d 100644
--- a/scm-ui/ui-components/src/MarkdownLinkRenderer.tsx
+++ b/scm-ui/ui-components/src/MarkdownLinkRenderer.tsx
@@ -30,10 +30,6 @@ type Props = RouteComponentProps & {
href: string;
};
-function flatten(text: string, child: any): any {
- return typeof child === "string" ? text + child : React.Children.toArray(child.props.children).reduce(flatten, text);
-}
-
/**
* Handle local SCM-Manager and external links
*
@@ -46,7 +42,7 @@ export function correctLocalLink(pathname: string, link: string) {
// Leave uris unchanged which start with schemes
const regex = new RegExp(".:");
- if (link.match(regex)) {
+ if (link.match(regex) || link.startsWith("#")) {
return link;
}
@@ -79,9 +75,7 @@ export function correctLocalLink(pathname: string, link: string) {
}
function MarkdownLinkRenderer(props: Props) {
const compositeUrl = withContextPath(correctLocalLink(props.location.pathname, props.href));
- const linkText = React.Children.toArray(props.children).reduce(flatten, "");
-
- return {linkText};
+ return {props.children};
}
export default withRouter(MarkdownLinkRenderer);