From 81c49d7636d9a1f447cfc1038aecd289a2c25bb9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 00:59:46 +0000 Subject: [PATCH] fix: add null checks for regex match results to satisfy TypeScript strict mode Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- packages/openapi-ts-tests/main/test/2.0.x.test.ts | 2 +- packages/openapi-ts-tests/main/test/3.0.x.test.ts | 2 +- packages/openapi-ts-tests/main/test/3.1.x.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/openapi-ts-tests/main/test/2.0.x.test.ts b/packages/openapi-ts-tests/main/test/2.0.x.test.ts index 9edb12831..916d1645a 100644 --- a/packages/openapi-ts-tests/main/test/2.0.x.test.ts +++ b/packages/openapi-ts-tests/main/test/2.0.x.test.ts @@ -300,7 +300,7 @@ describe(`OpenAPI ${version}`, () => { ); // Deduplicate prefixes: Foo_Foo → Foo const m = clean.match(/^([A-Za-z\d]+)_\1([A-Za-z\d]*)$/); - if (m) clean = m[1] + m[2]; + if (m?.[1] && m?.[2] !== undefined) clean = m[1] + m[2]; return clean; }, }, diff --git a/packages/openapi-ts-tests/main/test/3.0.x.test.ts b/packages/openapi-ts-tests/main/test/3.0.x.test.ts index 22fff3851..b39fcff4e 100644 --- a/packages/openapi-ts-tests/main/test/3.0.x.test.ts +++ b/packages/openapi-ts-tests/main/test/3.0.x.test.ts @@ -603,7 +603,7 @@ describe(`OpenAPI ${version}`, () => { ); // Deduplicate prefixes: Foo_Foo → Foo const m = clean.match(/^([A-Za-z\d]+)_\1([A-Za-z\d]*)$/); - if (m) clean = m[1] + m[2]; + if (m?.[1] && m?.[2] !== undefined) clean = m[1] + m[2]; return clean; }, }, diff --git a/packages/openapi-ts-tests/main/test/3.1.x.test.ts b/packages/openapi-ts-tests/main/test/3.1.x.test.ts index 0ed636eae..2a42d0494 100644 --- a/packages/openapi-ts-tests/main/test/3.1.x.test.ts +++ b/packages/openapi-ts-tests/main/test/3.1.x.test.ts @@ -705,7 +705,7 @@ describe(`OpenAPI ${version}`, () => { ); // Deduplicate prefixes: Foo_Foo → Foo const m = clean.match(/^([A-Za-z\d]+)_\1([A-Za-z\d]*)$/); - if (m) clean = m[1] + m[2]; + if (m?.[1] && m?.[2] !== undefined) clean = m[1] + m[2]; return clean; }, }, -- 2.51.2