Skip to content

Commit d05f0c1

Browse files
committed
fix(client): preserve quoted commas in PR filters
1 parent c82b8fd commit d05f0c1

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, expect, it } from "vite-plus/test";
2+
import { parsePullRequestQuery } from "./pullRequestQuery.ts";
3+
4+
describe("quoted commas in PR qualifier lists", () => {
5+
it.each([
6+
['label:"needs,triage",wip', { labels: [["needs,triage", "wip"]] }],
7+
[
8+
'label:wip,"needs,triage","needs design"',
9+
{ labels: [["wip", "needs,triage", "needs design"]] },
10+
],
11+
['-label:"needs,triage",wip', { excludedLabels: ["needs,triage", "wip"] }],
12+
['area:"web,mobile",server', { labels: [["area:web,mobile", "area:server"]] }],
13+
])("keeps quoted names whole in %s", (query, filters) => {
14+
expect(parsePullRequestQuery(query)).toEqual({ text: "", filters });
15+
});
16+
});

‎packages/client-runtime/src/pullRequestQuery.ts‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,7 @@ function qualifierValue(raw: string): string {
3232

3333
/** A qualifier's value as the list it may be: split on commas, each name unquoted on its own. */
3434
function splitQualifierList(raw: string): string[] {
35-
// Quoting names one whole label however many commas it holds: `label:"needs,triage"` asks for
36-
// the label written that way, not for either half of it.
37-
if (/^\s*"[^"]*"\s*$/.test(raw)) {
38-
const whole = qualifierValue(raw);
39-
return whole.length === 0 ? [] : [whole];
40-
}
41-
return raw
42-
.split(",")
35+
return (raw.match(/(?:[^,"]|"[^"]*")+/g) ?? [])
4336
.map((part) => qualifierValue(part))
4437
.filter((part) => part.length > 0);
4538
}

0 commit comments

Comments
 (0)