File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ function evaluateValue (expression) {
48
48
if ( ! expression . match ( stringRE ) ) { return ret }
49
49
50
50
try {
51
- const val = ( new Function ( `return ${ expression } ` ) ) ( )
51
+ const val = ( new Function ( `return ${ expression . trim ( ) } ` ) ) ( )
52
52
ret . status = 'ok'
53
53
ret . value = val
54
54
} catch ( e ) { }
Original file line number Diff line number Diff line change @@ -28,4 +28,12 @@ it('string literal containing period delimited ecmascript keywords should evalua
28
28
const { status, value } = evaluateValue ( `'new.alert.import'` )
29
29
expect ( status ) . toEqual ( 'ok' )
30
30
expect ( value ) . toEqual ( 'new.alert.import' )
31
+ } )
32
+
33
+ it ( 'string literal containing whitespace and newline keywords should evaluate' , ( ) => {
34
+ const { status, value } = evaluateValue ( `
35
+ 'hello'
36
+ ` )
37
+ expect ( status ) . toEqual ( 'ok' )
38
+ expect ( value ) . toEqual ( 'hello' )
31
39
} )
You can’t perform that action at this time.
0 commit comments