yamltest 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core.js +17 -0
package/package.json
CHANGED
package/src/core.js
CHANGED
|
@@ -599,6 +599,23 @@ async function executeHttpTest(test) {
|
|
|
599
599
|
|
|
600
600
|
test.http.url = resolveEnvVarsInUrl(test.http.url);// Resolve environment variables in URL
|
|
601
601
|
test.http.method = test.http.method || 'GET';
|
|
602
|
+
|
|
603
|
+
// If the url contains a path component (beyond '/'), extract it and prepend it to the explicit
|
|
604
|
+
// path field so that both forms below are equivalent:
|
|
605
|
+
// form 1: url: "http://host:80" path: /post
|
|
606
|
+
// form 2: url: "http://host:80/post" (no explicit path)
|
|
607
|
+
if (test.http.url) {
|
|
608
|
+
const parsedUrl = new URL(test.http.url);
|
|
609
|
+
const urlPath = parsedUrl.pathname + (parsedUrl.search || '');
|
|
610
|
+
if (urlPath && urlPath !== '/') {
|
|
611
|
+
// Strip the path/query from the base url
|
|
612
|
+
test.http.url = `${parsedUrl.protocol}//${parsedUrl.host}`;
|
|
613
|
+
// Prepend the extracted path to any explicit path (avoid double slashes)
|
|
614
|
+
const explicitPath = test.http.path || '';
|
|
615
|
+
test.http.path = urlPath.replace(/\/$/, '') + (explicitPath ? (explicitPath.startsWith('/') ? explicitPath : '/' + explicitPath) : '');
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
602
619
|
test.http.path = test.http.path || '/';
|
|
603
620
|
|
|
604
621
|
// Resolve environment variables in headers
|