From afd140289efa91ee9d6d7adf1602e6e6acd7a60a Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Wed, 22 May 2024 21:53:56 -0700 Subject: [PATCH] Reserve some characters for future use --- src/index.spec.ts | 2 +- src/index.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.spec.ts b/src/index.spec.ts index b0bffac..b7a9228 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -1935,7 +1935,7 @@ const TESTS: Test[] = [ [[undefined, "/(testing)"]], ], [ - "/.\\+\\*\\?\\{\\}=^!\\:$[]|", + "/.\\+\\*\\?\\{\\}=^\\!\\:$[]\\|", undefined, ["/.+*?{}=^!:$[]|"], [["/.+*?{}=^!:$[]|", ["/.+*?{}=^!:$[]|"]]], diff --git a/src/index.ts b/src/index.ts index 0d5ee95..d7517da 100644 --- a/src/index.ts +++ b/src/index.ts @@ -90,6 +90,7 @@ interface LexToken { | "CHAR" | "ESCAPED_CHAR" | "MODIFIER" + | "RESERVED" | "END"; index: number; value: string; @@ -106,6 +107,11 @@ function lexer(str: string) { while (i < chars.length) { const char = chars[i]; + if (char === "!" || char === ";" || char === "|") { + tokens.push({ type: "RESERVED", index: i, value: chars[i++] }); + continue; + } + if (char === "*" || char === "+" || char === "?") { tokens.push({ type: "MODIFIER", index: i, value: chars[i++] }); continue; @@ -510,6 +516,7 @@ function matchRegexp

( ): MatchFunction

{ const { decode = decodeURIComponent, loose = DEFAULT_DELIMITER } = options; const stringify = toStringify(loose); + const decoders = keys.map((key) => { if (key.separator) { const re = new RegExp(