@@ -292,7 +292,7 @@ function $asDatetime (date, skipQuotes) {
292292 } else if ( date && typeof date . toISOString === 'function' ) {
293293 return quotes + date . toISOString ( ) + quotes
294294 } else {
295- return $asString ( date )
295+ return $asString ( date , skipQuotes )
296296 }
297297}
298298
@@ -306,7 +306,7 @@ function $asDate (date, skipQuotes) {
306306 } else if ( date && typeof date . format === 'function' ) {
307307 return quotes + date . format ( 'YYYY-MM-DD' ) + quotes
308308 } else {
309- return $asString ( date )
309+ return $asString ( date , skipQuotes )
310310 }
311311}
312312
@@ -320,20 +320,26 @@ function $asTime (date, skipQuotes) {
320320 } else if ( date && typeof date . format === 'function' ) {
321321 return quotes + date . format ( 'HH:mm:ss' ) + quotes
322322 } else {
323- return $asString ( date )
323+ return $asString ( date , skipQuotes )
324324 }
325325}
326326
327- function $asString ( str ) {
327+ function $asString ( str , skipQuotes ) {
328+ const quotes = skipQuotes === true ? '' : '"'
328329 if ( str instanceof Date ) {
329- return '"' + str . toISOString ( ) + '"'
330+ return quotes + str . toISOString ( ) + quotes
330331 } else if ( str === null ) {
331- return '""'
332+ return quotes + quotes
332333 } else if ( str instanceof RegExp ) {
333334 str = str . source
334335 } else if ( typeof str !== 'string' ) {
335336 str = str . toString ( )
336337 }
338+ // If we skipQuotes it means that we are using it as test
339+ // no need to test the string length for the render
340+ if ( skipQuotes ) {
341+ return str
342+ }
337343
338344 if ( str . length < 42 ) {
339345 return $asStringSmall ( str )
0 commit comments