File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
packages/repl/src/lib/Output/console Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 9797
9898 return formatted ;
9999 }
100+
101+ const chars: Record <string , string > = {
102+ ' &' : ' &' ,
103+ ' <' : ' <' ,
104+ ' >' : ' >'
105+ };
106+
107+ function escape_html(html : string ) {
108+ return html .replace (/ [&<>] / g , (c ) => chars [c ]);
109+ }
110+
111+ function link(str : string ) {
112+ return str .replace (
113+ / (http| ftp| https):\/\/ ([\w _-] + (?:(?:\. [\w _-] + )+ ))([\w. ,@?^=%&:\/ ~+#-] * [\w @?^=%&\/ ~+#-] )/ g ,
114+ (m ) => ` <a target="_blank" href="${m }">${m }</a> `
115+ );
116+ }
100117 </script >
101118
102119{#if log .command === ' table' }
108125 <div
109126 role =" button"
110127 tabindex =" 0"
111- on:click ={toggle_group_collapse }
128+ onclick ={toggle_group_collapse }
112129 class =" log"
113130 class:expandable ={log .stack || log .command === ' group' }
114131 >
135152 {/if }{#if part .type === ' value' }
136153 <JSONNode value ={part .value } defaultExpandedLevel ={log .expanded ? 1 : 0 } />
137154 {:else }
138- <span class ="styled" style ={part .style }>{part .value }</span >
155+ <!-- svelte-ignore a11y_no_static_element_interactions -->
156+ <span class ="styled" style ={part .style } onclick ={(e ) => e .stopPropagation ()}>
157+ {@html link (escape_html (part .value ))}
158+ </span >
139159 {/if }
140160 {/each }
141161 </span >
You can’t perform that action at this time.
0 commit comments