Skip to content

Commit 7b1e139

Browse files
committed
Make functions match only with word
1 parent 706d004 commit 7b1e139

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const highlighters = [
2929
},
3030
{
3131
name: 'function',
32-
regex: /(\w*?)\(/g,
32+
regex: /(\w+?)\(/g,
3333
trimEnd: 1
3434
},
3535
{
@@ -48,12 +48,14 @@ const highlighters = [
4848

4949
function highlight (sqlString, options) {
5050
options = Object.assign({}, DEFAULT_OPTIONS, options)
51-
51+
5252
const matches = []
5353

5454
for (const hl of highlighters) {
5555
let match
56-
56+
57+
// This is probably the one time when an assignment inside a condidion makes sense
58+
// eslint-disable-next-line no-cond-assign
5759
while (match = hl.regex.exec(sqlString)) {
5860
matches.push({
5961
name: hl.name,
@@ -66,7 +68,7 @@ function highlight (sqlString, options) {
6668
const sortedMatches = matches.slice().sort((a, b) => a.start - b.start)
6769

6870
// filter/exclude nested matches (matches within the last match)
69-
let filteredMatches = []
71+
const filteredMatches = []
7072
let upperBound = 0
7173
for (let i = 0; i < sortedMatches.length; i++) {
7274
if (sortedMatches[i].start >= upperBound) {

0 commit comments

Comments
 (0)