Skip to content

Commit 35a15d5

Browse files
committed
Simplify name loop during parse
1 parent 8a39eee commit 35a15d5

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/index.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const DEFAULT_PREFIXES = "./";
22
const DEFAULT_DELIMITER = "/";
33
const GROUPS_RE = /\((?:\?<(.*?)>)?(?!\?)/g;
44
const NOOP_VALUE = (value: string) => value;
5-
const NAME_RE = /^[\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}]$/u;
5+
const NAME_RE = /^[\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}$]$/u;
66

77
/**
88
* Encode a string into another string.
@@ -130,13 +130,8 @@ function lexer(str: string) {
130130
let name = "";
131131
let j = i + 1;
132132

133-
while (j < chars.length) {
134-
if (NAME_RE.test(chars[j])) {
135-
name += chars[j++];
136-
continue;
137-
}
138-
139-
break;
133+
while (NAME_RE.test(chars[j])) {
134+
name += chars[j++];
140135
}
141136

142137
if (!name) throw new TypeError(`Missing parameter name at ${i}`);

0 commit comments

Comments
 (0)