From cd90f2be9c16c6d335b3808bef085bcb97544011 Mon Sep 17 00:00:00 2001 From: Vincent Date: Fri, 6 Sep 2024 16:35:17 +0200 Subject: [PATCH] fix: splitting queries incorrectly removed quotes This made it impossible to use any search queries with quotes in it. Closes #107 --- packages/github/src/search.ts | 1 + packages/github/tests/search.test.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/github/src/search.ts b/packages/github/src/search.ts index 546582d..41df96c 100644 --- a/packages/github/src/search.ts +++ b/packages/github/src/search.ts @@ -20,6 +20,7 @@ export function splitQueries(search: string): string[] { query = ""; } else if (c === '"') { quoted = !quoted; + query += c; } else { query += c; } diff --git a/packages/github/tests/search.test.ts b/packages/github/tests/search.test.ts index db6515b..cf6a315 100644 --- a/packages/github/tests/search.test.ts +++ b/packages/github/tests/search.test.ts @@ -128,7 +128,8 @@ test("split a search string into queries", () => { expect(splitQueries("a")).toEqual(["a"]); expect(splitQueries("a;b")).toEqual(["a", "b"]); expect(splitQueries(" a ; b ")).toEqual(["a", "b"]); - expect(splitQueries('"a;b";c')).toEqual(["a;b", "c"]); + expect(splitQueries(`"a"`)).toEqual([`"a"`]); + expect(splitQueries(`"a;b";c`)).toEqual([`"a;b"`, "c"]); expect(splitQueries("a; ;c")).toEqual(["a", "c"]); });