File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 11var SqlString = exports ;
2- var charsRegex = / [ \0 \b \t \n \r \x1a \" \' \\ ] / g; // eslint-disable-line no-control-regex
3- var charsMap = {
2+
3+ var CHARS_GLOBAL_REGEXP = / [ \0 \b \t \n \r \x1a \" \' \\ ] / g; // eslint-disable-line no-control-regex
4+ var CHARS_ESCAPE_MAP = {
45 '\0' : '\\0' ,
56 '\b' : '\\b' ,
67 '\t' : '\\t' ,
@@ -177,13 +178,13 @@ SqlString.objectToValues = function objectToValues(object, timeZone) {
177178} ;
178179
179180function escapeString ( val ) {
180- var chunkIndex = charsRegex . lastIndex = 0 ;
181+ var chunkIndex = CHARS_GLOBAL_REGEXP . lastIndex = 0 ;
181182 var escapedVal = '' ;
182183 var match ;
183184
184- while ( ( match = charsRegex . exec ( val ) ) ) {
185- escapedVal += val . slice ( chunkIndex , match . index ) + charsMap [ match [ 0 ] ] ;
186- chunkIndex = charsRegex . lastIndex ;
185+ while ( ( match = CHARS_GLOBAL_REGEXP . exec ( val ) ) ) {
186+ escapedVal += val . slice ( chunkIndex , match . index ) + CHARS_ESCAPE_MAP [ match [ 0 ] ] ;
187+ chunkIndex = CHARS_GLOBAL_REGEXP . lastIndex ;
187188 }
188189
189190 if ( chunkIndex === 0 ) {
You can’t perform that action at this time.
0 commit comments