@@ -35,6 +35,47 @@ function createBase64URL(mime, body) {
35
35
assert . deepStrictEqual ( Object . keys ( ns ) , [ 'default' ] ) ;
36
36
assert . deepStrictEqual ( ns . default , plainESMURL ) ;
37
37
}
38
+ {
39
+ const body = 'export default import.meta.url;' ;
40
+ const plainESMURL = createURL ( 'text/javascript;charset=UTF-8' , body ) ;
41
+ const ns = await import ( plainESMURL ) ;
42
+ assert . deepStrictEqual ( Object . keys ( ns ) , [ 'default' ] ) ;
43
+ assert . deepStrictEqual ( ns . default , plainESMURL ) ;
44
+ }
45
+ {
46
+ const body = 'export default import.meta.url;' ;
47
+ const plainESMURL = createURL ( 'text/javascript;charset="UTF-8"' , body ) ;
48
+ const ns = await import ( plainESMURL ) ;
49
+ assert . deepStrictEqual ( Object . keys ( ns ) , [ 'default' ] ) ;
50
+ assert . deepStrictEqual ( ns . default , plainESMURL ) ;
51
+ }
52
+ {
53
+ const body = 'export default import.meta.url;' ;
54
+ const plainESMURL = createURL ( 'text/javascript;;a=a;b=b;;' , body ) ;
55
+ const ns = await import ( plainESMURL ) ;
56
+ assert . deepStrictEqual ( Object . keys ( ns ) , [ 'default' ] ) ;
57
+ assert . deepStrictEqual ( ns . default , plainESMURL ) ;
58
+ }
59
+ {
60
+ const ns = await import ( 'data:application/json;foo="test,"this"' ) ;
61
+ assert . deepStrictEqual ( Object . keys ( ns ) , [ 'default' ] ) ;
62
+ assert . deepStrictEqual ( ns . default , 'this' ) ;
63
+ }
64
+ {
65
+ const ns = await import ( `data:application/json;foo=${
66
+ encodeURIComponent ( 'test,' )
67
+ } ,0`) ;
68
+ assert . deepStrictEqual ( Object . keys ( ns ) , [ 'default' ] ) ;
69
+ assert . deepStrictEqual ( ns . default , 0 ) ;
70
+ }
71
+ {
72
+ await assert . rejects ( async ( ) => {
73
+ return import ( 'data:application/json;foo="test,",0' ) ;
74
+ } , {
75
+ name : 'SyntaxError' ,
76
+ message : / U n e x p e c t e d e n d o f J S O N i n p u t /
77
+ } ) ;
78
+ }
38
79
{
39
80
const body = '{"x": 1}' ;
40
81
const plainESMURL = createURL ( 'application/json' , body ) ;
0 commit comments