Fix #2760: Path params trailing slash (#3065)

As reported in #2670, if a URL has a trailing slash and also contains
path parameters then the original logic had a bug that would drop the
trailing slash.
This implements the fix proposed by @ThenTech.
This commit is contained in:
Sam Briggs 2024-09-26 06:48:18 +01:00 committed by GitHub
parent 8e222189bc
commit 2dd5ae400c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -122,7 +122,8 @@ const interpolateVars = (request, envVars = {}, runtimeVariables = {}, processEn
}) })
.join(''); .join('');
request.url = url.origin + interpolatedUrlPath + url.search; const trailingSlash = url.pathname.endsWith('/') ? '/' : '';
request.url = url.origin + interpolatedUrlPath + trailingSlash + url.search;
} }
if (request.proxy) { if (request.proxy) {

View File

@ -120,7 +120,8 @@ const interpolateVars = (request, envVariables = {}, runtimeVariables = {}, proc
}) })
.join(''); .join('');
request.url = url.origin + urlPathnameInterpolatedWithPathParams + url.search; const trailingSlash = url.pathname.endsWith('/') ? '/' : '';
request.url = url.origin + urlPathnameInterpolatedWithPathParams + trailingSlash + url.search;
} }
if (request.proxy) { if (request.proxy) {