File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -374,7 +374,8 @@ registerScriptlet(trustedJsonEditFetchResponse, {
374
374
375
375
function jsonlEditFn ( jsonp , text = '' ) {
376
376
const safe = safeSelf ( ) ;
377
- const linesBefore = text . split ( / \n + / ) ;
377
+ const lineSeparator = / \r ? \n / . exec ( text ) ?. [ 0 ] || '\n' ;
378
+ const linesBefore = text . split ( lineSeparator ) ;
378
379
const linesAfter = [ ] ;
379
380
for ( const lineBefore of linesBefore ) {
380
381
let obj ;
@@ -387,9 +388,10 @@ function jsonlEditFn(jsonp, text = '') {
387
388
linesAfter . push ( lineBefore ) ;
388
389
continue ;
389
390
}
390
- linesAfter . push ( JSONPath . toJSON ( obj , safe . JSON_stringify ) ) ;
391
+ const lineAfter = safe . JSON_stringify ( obj ) ;
392
+ linesAfter . push ( lineAfter ) ;
391
393
}
392
- return linesAfter . join ( '\n' ) ;
394
+ return linesAfter . join ( lineSeparator ) ;
393
395
}
394
396
registerScriptlet ( jsonlEditFn , {
395
397
name : 'jsonl-edit.fn' ,
You can’t perform that action at this time.
0 commit comments