Skip to content

Commit a77cce3

Browse files
authored
fix: parseurl in Node returns only pathname when protocol not specified (#566)
1 parent e283827 commit a77cce3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/config-resolver/src/EndpointsConfig.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,20 @@ export interface EndpointsResolvedConfig
4343
export function resolveEndpointsConfig<T>(
4444
input: T & EndpointsInputConfig & PreviouslyResolved
4545
): T & EndpointsResolvedConfig {
46-
const tls = input.tls || true;
46+
const tls = input.tls === undefined ? true : input.tls;
4747
const endpoint: Provider<Endpoint> = input.endpoint
4848
? normalizeEndpoint(input.endpoint, input.urlParser)
4949
: () =>
5050
input.region().then(async region => {
5151
const hostname = (
5252
(await input.regionInfoProvider(region)) || ({} as RegionInfo)
5353
).hostname;
54-
if (!hostname)
54+
if (!hostname) {
5555
throw new Error("Cannot resolve hostname from client config");
56-
const endpoint = input.urlParser(hostname);
57-
endpoint.protocol = tls ? "https:" : "http:";
56+
}
57+
const endpoint = input.urlParser(
58+
`${tls ? "https:" : "http:"}//${hostname}`
59+
);
5860
return endpoint;
5961
});
6062
return {

0 commit comments

Comments
 (0)