From 3b9c311dc5f1c2112bc0aeb63827ef0815939ade Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 29 Jun 2026 14:32:21 -0700 Subject: [PATCH] Avoid regex trimming in OpenAPI importer --- plugins/importer-openapi/src/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/importer-openapi/src/index.ts b/plugins/importer-openapi/src/index.ts index 02e3ef4d..e08302bf 100644 --- a/plugins/importer-openapi/src/index.ts +++ b/plugins/importer-openapi/src/index.ts @@ -368,7 +368,19 @@ function interpolateServerUrl(server: UnknownRecord): string { function joinUrlParts(baseUrl: string, path: string): string { if (baseUrl.length === 0) return path; - return `${baseUrl.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`; + return `${trimTrailingSlashes(baseUrl)}/${trimLeadingSlashes(path)}`; +} + +function trimLeadingSlashes(value: string): string { + let index = 0; + while (value[index] === "/") index++; + return value.slice(index); +} + +function trimTrailingSlashes(value: string): string { + let index = value.length; + while (value[index - 1] === "/") index--; + return value.slice(0, index); } function importUrlParameters({