Skip to content

Commit 74b6361

Browse files
authored
Reduce what gets linked (#875)
1 parent 1efd7e2 commit 74b6361

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Opts } from "linkifyjs";
2+
3+
export const linkifyJsOptions: Opts = {
4+
rel: "noopener noreferrer",
5+
validate: {
6+
url: (value) => /^https?:\/\//.test(value),
7+
},
8+
};

src/main/frontend/pipeline-console-view/pipeline-console/main/ConsoleLine.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import linkifyHtml from "linkify-html";
22
import { memo, useEffect, useRef } from "react";
33

4+
import { linkifyJsOptions } from "../../../common/utils/linkify-js.ts";
45
import { makeReactChildren, tokenizeANSIString } from "./Ansi.tsx";
56

67
export interface ConsoleLineProps {
@@ -45,7 +46,7 @@ export const ConsoleLine = memo(function ConsoleLine(props: ConsoleLineProps) {
4546
className="console-text"
4647
>
4748
{makeReactChildren(
48-
tokenizeANSIString(linkifyHtml(props.content)),
49+
tokenizeANSIString(linkifyHtml(props.content, linkifyJsOptions)),
4950
`${props.stepId}-${props.lineNumber}`,
5051
)}
5152
</div>

src/main/frontend/pipeline-console-view/pipeline-console/main/ConsoleLogCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import StatusIcon from "../../../common/components/status-icon.tsx";
1212
import Tooltip from "../../../common/components/tooltip.tsx";
1313
import { LocalizedMessageKey, useMessages } from "../../../common/i18n";
1414
import { classNames } from "../../../common/utils/classnames.ts";
15+
import { linkifyJsOptions } from "../../../common/utils/linkify-js.ts";
1516
import LiveTotal from "../../../common/utils/live-total.tsx";
1617
import {
1718
LOG_FETCH_SIZE,
@@ -69,13 +70,13 @@ export default function ConsoleLogCard(props: ConsoleLogCardProps) {
6970

7071
{props.step.title !== "" && (
7172
<span>
72-
<Linkify>{props.step.title}</Linkify>
73+
<Linkify options={linkifyJsOptions}>{props.step.title}</Linkify>
7374
</span>
7475
)}
7576

7677
{props.step.name !== "" && (
7778
<span>
78-
<Linkify>{props.step.name}</Linkify>
79+
<Linkify options={linkifyJsOptions}>{props.step.name}</Linkify>
7980
</span>
8081
)}
8182

0 commit comments

Comments
 (0)