Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert urls in logs to links #3904

Merged
merged 2 commits into from
Jul 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion web/src/components/repo/pipeline/PipelineLog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,21 @@ function formatTime(time?: number): string {
return time === undefined ? '' : `${time}s`;
}

function processText(text: string): string {
const urlRegex = /https?:\/\/\S+/g;
let txt = ansiUp.value.ansi_to_html(`${decode(text)}\n`);
txt = txt.replace(
urlRegex,
(url) => `<a href="${url}" target="_blank" rel="noopener noreferrer" class="underline">${url}</a>`,
);
return txt;
}

function writeLog(line: Partial<LogLine>) {
logBuffer.value.push({
index: line.index ?? 0,
number: (line.index ?? 0) + 1,
text: ansiUp.value.ansi_to_html(`${decode(line.text ?? '')}\n`),
text: processText(line.text ?? ''),
time: line.time ?? 0,
type: null, // TODO: implement way to detect errors and warnings
});
Expand Down