mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 23:15:43 +01:00
Add another fragment test case which caused jenkins error
This commit is contained in:
@@ -30,6 +30,7 @@ const pathname = basePath + "README.md/";
|
|||||||
describe("correctLocalLink tests", () => {
|
describe("correctLocalLink tests", () => {
|
||||||
it("should return same url", () => {
|
it("should return same url", () => {
|
||||||
expect(correctLocalLink(pathname, "")).toBe(pathname);
|
expect(correctLocalLink(pathname, "")).toBe(pathname);
|
||||||
|
expect(correctLocalLink(pathname, "#42")).toBe("#42");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return main directory", () => {
|
it("should return main directory", () => {
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ type Props = RouteComponentProps & {
|
|||||||
href: string;
|
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
|
* 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
|
// Leave uris unchanged which start with schemes
|
||||||
const regex = new RegExp(".:");
|
const regex = new RegExp(".:");
|
||||||
if (link.match(regex)) {
|
if (link.match(regex) || link.startsWith("#")) {
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,9 +75,7 @@ export function correctLocalLink(pathname: string, link: string) {
|
|||||||
}
|
}
|
||||||
function MarkdownLinkRenderer(props: Props) {
|
function MarkdownLinkRenderer(props: Props) {
|
||||||
const compositeUrl = withContextPath(correctLocalLink(props.location.pathname, props.href));
|
const compositeUrl = withContextPath(correctLocalLink(props.location.pathname, props.href));
|
||||||
const linkText = React.Children.toArray(props.children).reduce(flatten, "");
|
return <a href={compositeUrl}>{props.children}</a>;
|
||||||
|
|
||||||
return <a href={compositeUrl}>{linkText}</a>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(MarkdownLinkRenderer);
|
export default withRouter(MarkdownLinkRenderer);
|
||||||
|
|||||||
Reference in New Issue
Block a user