Skip to content

Commit 0454dd6

Browse files
AllanZhengYPtrivikr
authored andcommitted
fix: parseurl in Node returns only pathname when protocol not specified (#566)
1 parent 272ae8d commit 0454dd6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: packages/config-resolver/src/EndpointsConfig.ts

+6-4
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)