File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -98,23 +98,24 @@ module.exports = class Serializer {
98
98
}
99
99
100
100
asString ( str ) {
101
- const quotes = '"'
102
- if ( str instanceof Date ) {
103
- return quotes + str . toISOString ( ) + quotes
104
- } else if ( str === null ) {
105
- return '""'
106
- } else if ( str instanceof RegExp ) {
107
- str = str . source
108
- } else if ( typeof str !== 'string' ) {
109
- str = str . toString ( )
101
+ if ( typeof str !== 'string' ) {
102
+ if ( str === null ) {
103
+ return '""'
104
+ }
105
+ if ( str instanceof Date ) {
106
+ return '"' + str . toISOString ( ) + '"'
107
+ }
108
+ if ( str instanceof RegExp ) {
109
+ str = str . source
110
+ } else {
111
+ str = str . toString ( )
112
+ }
110
113
}
111
114
112
115
// Fast escape chars check
113
116
if ( ! STR_ESCAPE . test ( str ) ) {
114
- return quotes + str + quotes
115
- }
116
-
117
- if ( str . length < 42 ) {
117
+ return '"' + str + '"'
118
+ } else if ( str . length < 42 ) {
118
119
return this . asStringSmall ( str )
119
120
} else {
120
121
return JSON . stringify ( str )
You can’t perform that action at this time.
0 commit comments