Skip to content

Commit

Permalink
Convert urls in logs to links (#3904)
Browse files Browse the repository at this point in the history
  • Loading branch information
anbraten authored Jul 13, 2024
1 parent 1c0073f commit f61bff2
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit f61bff2

Please sign in to comment.