File tree Expand file tree Collapse file tree 1 file changed +1
-15
lines changed Expand file tree Collapse file tree 1 file changed +1
-15
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ function build (schema, options) {
18
18
${ $asNumber . toString ( ) }
19
19
${ $asNull . toString ( ) }
20
20
${ $asBoolean . toString ( ) }
21
- ${ $asRegExp . toString ( ) }
22
21
`
23
22
var main
24
23
@@ -79,27 +78,14 @@ function $asString (str) {
79
78
if ( str instanceof Date ) {
80
79
return '"' + str . toISOString ( ) + '"'
81
80
} else if ( str instanceof RegExp ) {
82
- return $asRegExp ( str )
81
+ str = str . source
83
82
} else if ( typeof str !== 'string' ) {
84
83
str = str . toString ( )
85
84
}
86
85
87
86
return JSON . stringify ( str )
88
87
}
89
88
90
- function $asRegExp ( reg ) {
91
- reg = reg . source
92
-
93
- for ( var i = 0 , len = reg . length ; i < len ; i ++ ) {
94
- if ( reg [ i ] === '\\' || reg [ i ] === '"' ) {
95
- reg = reg . substring ( 0 , i ) + '\\' + reg . substring ( i ++ )
96
- len += 2
97
- }
98
- }
99
-
100
- return '"' + reg + '"'
101
- }
102
-
103
89
function addPatternProperties ( schema , externalSchema ) {
104
90
var pp = schema . patternProperties
105
91
let code = `
You can’t perform that action at this time.
0 commit comments