Skip to content

Commit

Permalink
Simplify name loop during parse
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed May 23, 2024
1 parent 8a39eee commit 35a15d5
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}`);
Expand Down

0 comments on commit 35a15d5

Please sign in to comment.