sql-escaper
Advanced tools
+16
-0
@@ -28,2 +28,3 @@ "use strict"; | ||
| singleQuote: 39, | ||
| backtick: 96, | ||
| backslash: 92, | ||
@@ -82,2 +83,15 @@ dash: 45, | ||
| } | ||
| if (currentChar === charCode.backtick) { | ||
| const length = sql.length; | ||
| for (let cursor = position + 1; cursor < length; cursor++) { | ||
| if (sql.charCodeAt(cursor) !== charCode.backtick) | ||
| continue; | ||
| if (sql.charCodeAt(cursor + 1) === charCode.backtick) { | ||
| cursor++; | ||
| continue; | ||
| } | ||
| return cursor + 1; | ||
| } | ||
| return length; | ||
| } | ||
| if (currentChar === charCode.dash && nextChar === charCode.dash) { | ||
@@ -100,2 +114,3 @@ const lineBreak = sql.indexOf('\n', position + 2); | ||
| if (code === charCode.singleQuote || | ||
| code === charCode.backtick || | ||
| code === charCode.dash || | ||
@@ -116,2 +131,3 @@ code === charCode.slash) { | ||
| if (code === charCode.singleQuote || | ||
| code === charCode.backtick || | ||
| code === charCode.dash || | ||
@@ -118,0 +134,0 @@ code === charCode.slash) { |
+15
-2
@@ -21,2 +21,3 @@ import { Buffer } from "node:buffer"; | ||
| singleQuote: 39, | ||
| backtick: 96, | ||
| backslash: 92, | ||
@@ -62,2 +63,14 @@ dash: 45, | ||
| } | ||
| if (currentChar === charCode.backtick) { | ||
| const length = sql.length; | ||
| for (let cursor = position + 1; cursor < length; cursor++) { | ||
| if (sql.charCodeAt(cursor) !== charCode.backtick) continue; | ||
| if (sql.charCodeAt(cursor + 1) === charCode.backtick) { | ||
| cursor++; | ||
| continue; | ||
| } | ||
| return cursor + 1; | ||
| } | ||
| return length; | ||
| } | ||
| if (currentChar === charCode.dash && nextChar === charCode.dash) { | ||
@@ -78,3 +91,3 @@ const lineBreak = sql.indexOf("\n", position + 2); | ||
| if (code === charCode.questionMark) return position; | ||
| if (code === charCode.singleQuote || code === charCode.dash || code === charCode.slash) { | ||
| if (code === charCode.singleQuote || code === charCode.backtick || code === charCode.dash || code === charCode.slash) { | ||
| const contextEnd = skipSqlContext(sql, position); | ||
@@ -91,3 +104,3 @@ if (contextEnd !== -1) position = contextEnd - 1; | ||
| const lower = code | 32; | ||
| if (code === charCode.singleQuote || code === charCode.dash || code === charCode.slash) { | ||
| if (code === charCode.singleQuote || code === charCode.backtick || code === charCode.dash || code === charCode.slash) { | ||
| const contextEnd = skipSqlContext(sql, position); | ||
@@ -94,0 +107,0 @@ if (contextEnd !== -1) { |
+1
-1
| { | ||
| "name": "sql-escaper", | ||
| "version": "1.3.2", | ||
| "version": "1.3.3", | ||
| "description": "🛡️ Faster SQL escape and format for JavaScript (Node.js, Bun, and Deno).", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
44574
2.26%726
4.16%