Skip to content

Commit aca4d44

Browse files
committed
refactor(js,ts): rename parameter key to capturedValue
1 parent 3192740 commit aca4d44

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

examples/js/express/mysql/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const pool = mysql.createPool({
1616
if (!values) {
1717
return query
1818
}
19-
return query.replace(/\:(\w+)/g, function(matchedSubstring, key) {
20-
if (values.hasOwnProperty(key)) {
21-
return this.escape(values[key])
19+
return query.replace(/\:(\w+)/g, function(matchedSubstring, capturedValue) {
20+
if (values.hasOwnProperty(capturedValue)) {
21+
return this.escape(values[capturedValue])
2222
}
2323
return matchedSubstring
2424
}.bind(this))

examples/ts/express/mysql/app.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const pool = mysql.createPool({
1717
if (!values) {
1818
return query
1919
}
20-
return query.replace(/\:(\w+)/g, function(matchedSubstring, key) {
21-
if (values.hasOwnProperty(key)) {
22-
return this.escape(values[key])
20+
return query.replace(/\:(\w+)/g, function(matchedSubstring, capturedValue) {
21+
if (values.hasOwnProperty(capturedValue)) {
22+
return this.escape(values[capturedValue])
2323
}
2424
return matchedSubstring
2525
}.bind(this))

src/templates/app.js.ejs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const pool = mysql.createPool({
1717
return query
1818
}
1919
<%- // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_function_as_the_replacement -%>
20-
return query.replace(/\:(\w+)/g, function(matchedSubstring, key) {
21-
if (values.hasOwnProperty(key)) {
22-
return this.escape(values[key])
20+
return query.replace(/\:(\w+)/g, function(matchedSubstring, capturedValue) {
21+
if (values.hasOwnProperty(capturedValue)) {
22+
return this.escape(values[capturedValue])
2323
}
2424
return matchedSubstring
2525
}.bind(this))

src/templates/app.ts.ejs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const pool = mysql.createPool({
1818
return query
1919
}
2020
<%- // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_function_as_the_replacement -%>
21-
return query.replace(/\:(\w+)/g, function(matchedSubstring, key) {
22-
if (values.hasOwnProperty(key)) {
23-
return this.escape(values[key])
21+
return query.replace(/\:(\w+)/g, function(matchedSubstring, capturedValue) {
22+
if (values.hasOwnProperty(capturedValue)) {
23+
return this.escape(values[capturedValue])
2424
}
2525
return matchedSubstring
2626
}.bind(this))

0 commit comments

Comments
 (0)