From ce2ed1a605e9d8094985540b7bec1af0d37cfcbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Thu, 5 Dec 2024 11:57:13 +0100 Subject: [PATCH] chore: prefer charCodeAt --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index eeee78f..73e492e 100644 --- a/index.js +++ b/index.js @@ -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 @@ -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++ }