Skip to content

Commit

Permalink
chore: prefer charCodeAt (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday authored Dec 18, 2024
1 parent aa96bdb commit 1e3fd64
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Router (opts) {
assert(typeof opts.querystringParser === 'function', 'querystringParser must be a function')
this.querystringParser = opts.querystringParser
} else {
this.querystringParser = (query) => query === '' ? {} : querystring.parse(query)
this.querystringParser = (query) => query.length === 0 ? {} : querystring.parse(query)
}

this.caseSensitive = opts.caseSensitive === undefined ? true : opts.caseSensitive
Expand Down Expand Up @@ -792,15 +792,15 @@ function getClosingParenthensePosition (path, idx) {
while (idx < path.length) {
idx++

// ignore skipped chars
if (path[idx] === '\\') {
// ignore skipped chars "\"
if (path.charCodeAt(idx) === 92) {
idx++
continue
}

if (path[idx] === ')') {
if (path.charCodeAt(idx) === 41) {
parentheses--
} else if (path[idx] === '(') {
} else if (path.charCodeAt(idx) === 40) {
parentheses++
}

Expand Down

0 comments on commit 1e3fd64

Please sign in to comment.