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