diff --git a/extensions/clickclack/src/group-policy.test.ts b/extensions/clickclack/src/group-policy.test.ts index 09bd61ed7ce6..cb438087d745 100644 --- a/extensions/clickclack/src/group-policy.test.ts +++ b/extensions/clickclack/src/group-policy.test.ts @@ -117,16 +117,12 @@ describe("resolveClickClackGroupPolicy", () => { expect(result.requireMention).toBe(false); }); - it("trims channel id keys", () => { - // Edge case: leading/trailing whitespace is trimmed during resolution - // but our test passes raw channelId as is; exact match requires - // the trimmed key. The resolver does not trim; the caller must trim. - // Validating that untrimmed exact match works. + it("trims inbound channel ids before lookup", () => { const result = resolveClickClackGroupPolicy({ account: { - groups: { "chn_exact ": { requireMention: true } }, + groups: { chn_exact: { requireMention: true } }, }, - channelId: "chn_exact ", + channelId: " chn_exact ", }); expect(result.requireMention).toBe(true); }); diff --git a/extensions/clickclack/src/group-policy.ts b/extensions/clickclack/src/group-policy.ts index 85192466a694..51895930f15e 100644 --- a/extensions/clickclack/src/group-policy.ts +++ b/extensions/clickclack/src/group-policy.ts @@ -35,9 +35,7 @@ export function resolveClickClackGroupPolicy(params: { }; const wildcard = account.groups?.["*"]; const channelKey = channelId?.trim(); - const exact = channelKey - ? Object.entries(account.groups ?? {}).find(([key]) => key.trim() === channelKey)?.[1] - : undefined; + const exact = channelKey ? account.groups?.[channelKey] : undefined; // Channel rules are partial overrides. Resolve each field independently so // an exact channel rule can inherit unspecified fields from the wildcard // rule before falling back to the account-level policy.