From 1ba4f154d2ba06910cb8254d0bedce972e67cc3d Mon Sep 17 00:00:00 2001 From: saurabhsharma2u <41580629+saurabhsharma2u@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:23:08 +0000 Subject: [PATCH] test(core): add coverage for normalizeUrl error path Add tests to verify that `normalizeUrl` returns null when invalid URLs are provided, ensuring the error handling block is correctly exercised. This covers cases where `new URL()` throws an error. --- plugins/core/tests/normalize.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/core/tests/normalize.test.ts b/plugins/core/tests/normalize.test.ts index f1bb9f8..6454da4 100644 --- a/plugins/core/tests/normalize.test.ts +++ b/plugins/core/tests/normalize.test.ts @@ -95,6 +95,12 @@ test('normalizeUrl: skip non-HTML assets', () => { expect(normalizeUrl('https://example.com/page', '')).toBe('https://example.com/page'); }); +test('normalizeUrl: invalid URL', () => { + expect(normalizeUrl('/foo', '')).toBeNull(); + expect(normalizeUrl('invalid-url', '')).toBeNull(); + expect(normalizeUrl('/foo', 'invalid-base')).toBeNull(); +}); + test('normalizeUrl: return format', () => { const res = normalizeUrl('https://example.com/foo?a=1', ''); expect(res).toBe('https://example.com/foo?a=1');