File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -258,7 +258,7 @@ module.exports = function serialize(obj, options) {
258258 }
259259
260260 if ( type === 'L' ) {
261- return "new URL(\"" + urls [ valueIndex ] . toString ( ) + "\" )" ;
261+ return "new URL(" + serialize ( urls [ valueIndex ] . toString ( ) , options ) + ")" ;
262262 }
263263
264264 var fn = functions [ valueIndex ] ;
Original file line number Diff line number Diff line change @@ -461,8 +461,8 @@ describe('serialize( obj )', function () {
461461 describe ( 'URL' , function ( ) {
462462 it ( 'should serialize URL' , function ( ) {
463463 var u = new URL ( 'https://x.com/' )
464- expect ( serialize ( u ) ) . to . equal ( 'new URL("https://x .com/ ")' ) ;
465- expect ( serialize ( { t : [ u ] } ) ) . to . be . a ( 'string' ) . equal ( '{"t":[new URL("https://x .com/ ")]}' ) ;
464+ expect ( serialize ( u ) ) . to . equal ( 'new URL("https:\\u002F\\u002Fx .com\\u002F ")' ) ;
465+ expect ( serialize ( { t : [ u ] } ) ) . to . be . a ( 'string' ) . equal ( '{"t":[new URL("https:\\u002F\\u002Fx .com\\u002F ")]}' ) ;
466466 } ) ;
467467
468468 it ( 'should deserialize URL' , function ( ) {
@@ -477,6 +477,8 @@ describe('serialize( obj )', function () {
477477 expect ( serialize ( '</script>' ) ) . to . equal ( '"\\u003C\\u002Fscript\\u003E"' ) ;
478478 expect ( JSON . parse ( serialize ( '</script>' ) ) ) . to . equal ( '</script>' ) ;
479479 expect ( eval ( serialize ( '</script>' ) ) ) . to . equal ( '</script>' ) ;
480+ expect ( serialize ( new URL ( 'x:</script>' ) ) ) . to . equal ( 'new URL("x:\\u003C\\u002Fscript\\u003E")' ) ;
481+ expect ( eval ( serialize ( new URL ( 'x:</script>' ) ) ) . href ) . to . equal ( 'x:</script>' ) ;
480482 } ) ;
481483 } ) ;
482484
You can’t perform that action at this time.
0 commit comments