From 3eb39ef2629833efbd8cda4ee5e324aa428c3ac3 Mon Sep 17 00:00:00 2001 From: Tyler Dane Date: Thu, 23 Apr 2026 11:39:19 -0700 Subject: [PATCH] test(backend): add coverage for getEmailFromUrl decoding edge cases Tests for PR #1666 which replaces manual %40 replacement with decodeURIComponent: validates multi-char decoding, malformed percent-encoding null fallback, and missing calendar segment. Co-Authored-By: Claude Sonnet 4.6 --- .../src/common/services/gcal/gcal.util.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/backend/src/common/services/gcal/gcal.util.test.ts b/packages/backend/src/common/services/gcal/gcal.util.test.ts index 58fd0f6b8..f27bb9b1f 100644 --- a/packages/backend/src/common/services/gcal/gcal.util.test.ts +++ b/packages/backend/src/common/services/gcal/gcal.util.test.ts @@ -94,4 +94,17 @@ describe("Gaxios response parsing", () => { "https://www.googleapis.com/calendar/v3/calendars/foo%40bar.com/events?syncToken=!!!!!!!!!!!!!!!jqgYQwNWZ_QyyHyycChpiZHJvaGl1aHyyyyyyymxvZmMwaXZodjN2ZxoMCO7Xj6sGEICGncADwD4B"; expect(getEmailFromUrl(url)).toBe("foo@bar.com"); }); + it("decodes additional percent-encoded characters beyond %40", () => { + const url = + "https://www.googleapis.com/calendar/v3/calendars/foo%2Bbar%40example.com/events"; + expect(getEmailFromUrl(url)).toBe("foo+bar@example.com"); + }); + it("returns null for malformed percent-encoding", () => { + const url = + "https://www.googleapis.com/calendar/v3/calendars/foo%GGbar%40example.com/events"; + expect(getEmailFromUrl(url)).toBeNull(); + }); + it("returns null when URL has no calendar segment", () => { + expect(getEmailFromUrl("https://www.googleapis.com/calendar/v3/events")).toBeNull(); + }); });