18 lines
595 B
JavaScript
18 lines
595 B
JavaScript
import { parseUrl } from "@smithy/url-parser";
|
|
export const toEndpointV1 = (endpoint) => {
|
|
if (typeof endpoint === "object") {
|
|
if ("url" in endpoint) {
|
|
const v1Endpoint = parseUrl(endpoint.url);
|
|
if (endpoint.headers) {
|
|
v1Endpoint.headers = {};
|
|
for (const [name, values] of Object.entries(endpoint.headers)) {
|
|
v1Endpoint.headers[name.toLowerCase()] = values.join(", ");
|
|
}
|
|
}
|
|
return v1Endpoint;
|
|
}
|
|
return endpoint;
|
|
}
|
|
return parseUrl(endpoint);
|
|
};
|