From 35a15d57677714b197af4ae8add44f137b834abe Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Wed, 22 May 2024 20:54:45 -0700 Subject: [PATCH] Simplify name loop during parse --- src/index.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 19cd772..0d5ee95 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ const DEFAULT_PREFIXES = "./"; const DEFAULT_DELIMITER = "/"; const GROUPS_RE = /\((?:\?<(.*?)>)?(?!\?)/g; const NOOP_VALUE = (value: string) => value; -const NAME_RE = /^[\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}]$/u; +const NAME_RE = /^[\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}$]$/u; /** * Encode a string into another string. @@ -130,13 +130,8 @@ function lexer(str: string) { let name = ""; let j = i + 1; - while (j < chars.length) { - if (NAME_RE.test(chars[j])) { - name += chars[j++]; - continue; - } - - break; + while (NAME_RE.test(chars[j])) { + name += chars[j++]; } if (!name) throw new TypeError(`Missing parameter name at ${i}`);