Skip to content

Commit c2e3879

Browse files
authored
fix: fix ansi link color + regex (#3440)
1 parent 327ae70 commit c2e3879

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

assets/components/LogViewer/LogItem.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,3 @@ const { hosts } = useHosts();
2626
const container = currentContainer(toRef(() => logEntry.containerID));
2727
const host = computed(() => hosts.value[container.value.host]);
2828
</script>
29-
<style scoped lang="postcss">
30-
.log-wrapper :deep(a) {
31-
@apply text-primary underline-offset-4 hover:underline;
32-
}
33-
</style>

assets/components/LogViewer/SimpleLogItem.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ defineProps<{
2828
}>();
2929
3030
const colorize = (value: string) => ansiConvertor.toHtml(value);
31-
const urlPattern = /(https?:\/\/[^\s]+)/g;
31+
const urlPattern =
32+
/https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b[-a-zA-Z0-9()@:%_+.~#?&\/=]*/g;
3233
const linkify = (text: string) =>
3334
text.replace(urlPattern, (url) => `<a href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`);
3435
</script>
36+
37+
<style scoped lang="postcss">
38+
.log-wrapper :deep(a) {
39+
@apply text-primary underline-offset-4 hover:underline;
40+
}
41+
</style>

assets/components/LogViewer/__snapshots__/EventSource.spec.ts.snap

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
exports[`<ContainerEventSource /> > render html correctly > should render dates with 12 hour style 1`] = `
44
"<ul data-v-cf9ff940="" class="events group pt-4 medium" show-container-name="false">
55
<li data-v-cf9ff940="" data-key="1" data-time="1560336942459" class="group/entry">
6-
<div data-v-1344ff3d="" data-v-cf9ff940="" class="relative flex w-full items-start gap-x-2 group-[.compact]:items-stretch">
6+
<div data-v-a49e52d4="" data-v-cf9ff940="" class="relative flex w-full items-start gap-x-2 group-[.compact]:items-stretch">
77
<!--v-if-->
88
<!--v-if-->
99
<!--v-if-->
10-
<div data-v-961504e7="" data-v-1344ff3d="" class="tag inline-flex items-center justify-center rounded bg-base-lighter px-2 py-[0.2em] !items-start shrink-0 select-none" size="small">
10+
<div data-v-961504e7="" class="tag inline-flex items-center justify-center rounded bg-base-lighter px-2 py-[0.2em] !items-start shrink-0 select-none" size="small">
1111
<div class="inline-flex gap-2 whitespace-nowrap text-blue"><time datetime="2019-06-12T10:55:42.459Z" class="mobile-hidden">06/12/2019</time><time datetime="2019-06-12T10:55:42.459Z">10:55:42 AM</time></div>
1212
</div>
13-
<div data-v-e625cddd="" data-v-1344ff3d="" class="mt-1.5 size-2.5 flex-none rounded-lg flex select-none"></div>
14-
<div class="log-wrapper whitespace-pre-wrap [word-break:break-word] group-[.disable-wrap]:whitespace-nowrap">foo bar</div>
15-
<div class="flex gap-2 duration-250 absolute -right-1 opacity-0 transition-opacity delay-150 group-hover/entry:opacity-100">
13+
<div data-v-e625cddd="" class="mt-1.5 size-2.5 flex-none rounded-lg flex select-none"></div>
14+
<div data-v-a49e52d4="" class="log-wrapper whitespace-pre-wrap [word-break:break-word] group-[.disable-wrap]:whitespace-nowrap">foo bar</div>
15+
<div data-v-a49e52d4="" class="flex gap-2 duration-250 absolute -right-1 opacity-0 transition-opacity delay-150 group-hover/entry:opacity-100">
1616
<!--v-if-->
1717
</div>
1818
</div>
@@ -23,16 +23,16 @@ exports[`<ContainerEventSource /> > render html correctly > should render dates
2323
exports[`<ContainerEventSource /> > render html correctly > should render dates with 24 hour style 1`] = `
2424
"<ul data-v-cf9ff940="" class="events group pt-4 medium" show-container-name="false">
2525
<li data-v-cf9ff940="" data-key="1" data-time="1560336942459" class="group/entry">
26-
<div data-v-1344ff3d="" data-v-cf9ff940="" class="relative flex w-full items-start gap-x-2 group-[.compact]:items-stretch">
26+
<div data-v-a49e52d4="" data-v-cf9ff940="" class="relative flex w-full items-start gap-x-2 group-[.compact]:items-stretch">
2727
<!--v-if-->
2828
<!--v-if-->
2929
<!--v-if-->
30-
<div data-v-961504e7="" data-v-1344ff3d="" class="tag inline-flex items-center justify-center rounded bg-base-lighter px-2 py-[0.2em] !items-start shrink-0 select-none" size="small">
30+
<div data-v-961504e7="" class="tag inline-flex items-center justify-center rounded bg-base-lighter px-2 py-[0.2em] !items-start shrink-0 select-none" size="small">
3131
<div class="inline-flex gap-2 whitespace-nowrap text-blue"><time datetime="2019-06-12T10:55:42.459Z" class="mobile-hidden">06/12/2019</time><time datetime="2019-06-12T10:55:42.459Z">10:55:42</time></div>
3232
</div>
33-
<div data-v-e625cddd="" data-v-1344ff3d="" class="mt-1.5 size-2.5 flex-none rounded-lg flex select-none"></div>
34-
<div class="log-wrapper whitespace-pre-wrap [word-break:break-word] group-[.disable-wrap]:whitespace-nowrap">foo bar</div>
35-
<div class="flex gap-2 duration-250 absolute -right-1 opacity-0 transition-opacity delay-150 group-hover/entry:opacity-100">
33+
<div data-v-e625cddd="" class="mt-1.5 size-2.5 flex-none rounded-lg flex select-none"></div>
34+
<div data-v-a49e52d4="" class="log-wrapper whitespace-pre-wrap [word-break:break-word] group-[.disable-wrap]:whitespace-nowrap">foo bar</div>
35+
<div data-v-a49e52d4="" class="flex gap-2 duration-250 absolute -right-1 opacity-0 transition-opacity delay-150 group-hover/entry:opacity-100">
3636
<!--v-if-->
3737
</div>
3838
</div>
@@ -43,16 +43,16 @@ exports[`<ContainerEventSource /> > render html correctly > should render dates
4343
exports[`<ContainerEventSource /> > render html correctly > should render messages 1`] = `
4444
"<ul data-v-cf9ff940="" class="events group pt-4 medium" show-container-name="false">
4545
<li data-v-cf9ff940="" data-key="1" data-time="1560336942459" class="group/entry">
46-
<div data-v-1344ff3d="" data-v-cf9ff940="" class="relative flex w-full items-start gap-x-2 group-[.compact]:items-stretch">
46+
<div data-v-a49e52d4="" data-v-cf9ff940="" class="relative flex w-full items-start gap-x-2 group-[.compact]:items-stretch">
4747
<!--v-if-->
4848
<!--v-if-->
4949
<!--v-if-->
50-
<div data-v-961504e7="" data-v-1344ff3d="" class="tag inline-flex items-center justify-center rounded bg-base-lighter px-2 py-[0.2em] !items-start shrink-0 select-none" size="small">
50+
<div data-v-961504e7="" class="tag inline-flex items-center justify-center rounded bg-base-lighter px-2 py-[0.2em] !items-start shrink-0 select-none" size="small">
5151
<div class="inline-flex gap-2 whitespace-nowrap text-blue"><time datetime="2019-06-12T10:55:42.459Z" class="mobile-hidden">06/12/2019</time><time datetime="2019-06-12T10:55:42.459Z">10:55:42 AM</time></div>
5252
</div>
53-
<div data-v-e625cddd="" data-v-1344ff3d="" class="mt-1.5 size-2.5 flex-none rounded-lg flex select-none"></div>
54-
<div class="log-wrapper whitespace-pre-wrap [word-break:break-word] group-[.disable-wrap]:whitespace-nowrap">This is a message.</div>
55-
<div class="flex gap-2 duration-250 absolute -right-1 opacity-0 transition-opacity delay-150 group-hover/entry:opacity-100">
53+
<div data-v-e625cddd="" class="mt-1.5 size-2.5 flex-none rounded-lg flex select-none"></div>
54+
<div data-v-a49e52d4="" class="log-wrapper whitespace-pre-wrap [word-break:break-word] group-[.disable-wrap]:whitespace-nowrap">This is a message.</div>
55+
<div data-v-a49e52d4="" class="flex gap-2 duration-250 absolute -right-1 opacity-0 transition-opacity delay-150 group-hover/entry:opacity-100">
5656
<!--v-if-->
5757
</div>
5858
</div>

0 commit comments

Comments
 (0)