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 1
1
var 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 = {
4
5
'\0' : '\\0' ,
5
6
'\b' : '\\b' ,
6
7
'\t' : '\\t' ,
@@ -177,13 +178,13 @@ SqlString.objectToValues = function objectToValues(object, timeZone) {
177
178
} ;
178
179
179
180
function escapeString ( val ) {
180
- var chunkIndex = charsRegex . lastIndex = 0 ;
181
+ var chunkIndex = CHARS_GLOBAL_REGEXP . lastIndex = 0 ;
181
182
var escapedVal = '' ;
182
183
var match ;
183
184
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 ;
187
188
}
188
189
189
190
if ( chunkIndex === 0 ) {
You can’t perform that action at this time.
0 commit comments