File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed
components/Preview/DevTools/Tests/TestDetails/ErrorDetails Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import styled from 'styled-components';
33import theme from '@codesandbox/common/lib/theme' ;
44import ansiHTML from 'ansi-html' ;
55
6+ import { escapeHtml } from 'app/utils/escape' ;
7+
68import { TestError } from '../../' ;
79
810const Container = styled . div `
@@ -22,15 +24,6 @@ const Container = styled.div`
2224 }
2325` ;
2426
25- function escapeHtml ( unsafe ) {
26- return unsafe
27- . replace ( / & / g, '&' )
28- . replace ( / < / g, '<' )
29- . replace ( / > / g, '>' )
30- . replace ( / " / g, '"' )
31- . replace ( / ' / g, ''' ) ;
32- }
33-
3427const formatDiffMessage = ( error : TestError , path : string ) => {
3528 let finalMessage : string = '' ;
3629 if ( error . matcherResult ) {
@@ -92,7 +85,7 @@ const formatDiffMessage = (error: TestError, path: string) => {
9285 ? `<span style="color:${ theme . red ( ) } ;">></span> `
9386 : '' ) +
9487 newMargin . join ( '' ) +
95- code . lineNumber +
88+ escapeHtml ( '' + code . lineNumber ) +
9689 ' | ' +
9790 escapeHtml ( code . content ) +
9891 '</div>' ;
Original file line number Diff line number Diff line change 1+ export function escapeHtml ( unsafe : string ) {
2+ return unsafe
3+ . replace ( / & / g, '&' )
4+ . replace ( / < / g, '<' )
5+ . replace ( / > / g, '>' )
6+ . replace ( / " / g, '"' )
7+ . replace ( / ' / g, ''' ) ;
8+ }
You can’t perform that action at this time.
0 commit comments