mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-06-30 10:01:42 +02:00
Avoid regex trimming in OpenAPI importer
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user