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 97
97
98
98
return formatted ;
99
99
}
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
+ }
100
117
</script >
101
118
102
119
{#if log .command === ' table' }
108
125
<div
109
126
role =" button"
110
127
tabindex =" 0"
111
- on:click ={toggle_group_collapse }
128
+ onclick ={toggle_group_collapse }
112
129
class =" log"
113
130
class:expandable ={log .stack || log .command === ' group' }
114
131
>
135
152
{/if }{#if part .type === ' value' }
136
153
<JSONNode value ={part .value } defaultExpandedLevel ={log .expanded ? 1 : 0 } />
137
154
{: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 >
139
159
{/if }
140
160
{/each }
141
161
</span >
You can’t perform that action at this time.
0 commit comments