diff --git a/packages/repl/src/lib/Output/console/ConsoleLine.svelte b/packages/repl/src/lib/Output/console/ConsoleLine.svelte index d5fe669cf5..b188d262f4 100644 --- a/packages/repl/src/lib/Output/console/ConsoleLine.svelte +++ b/packages/repl/src/lib/Output/console/ConsoleLine.svelte @@ -97,6 +97,23 @@ return formatted; } + + const chars: Record = { + '&': '&', + '<': '<', + '>': '>' + }; + + function escape_html(html: string) { + return html.replace(/[&<>]/g, (c) => chars[c]); + } + + function link(str: string) { + return str.replace( + /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])/g, + (m) => `${m}` + ); + } {#if log.command === 'table'} @@ -108,7 +125,7 @@
@@ -135,7 +152,10 @@ {/if}{#if part.type === 'value'} {:else} - {part.value} + + e.stopPropagation()}> + {@html link(escape_html(part.value))} + {/if} {/each}