Skip to content

Commit

Permalink
fix: parseurl in Node returns only pathname when protocol not specifi…
Browse files Browse the repository at this point in the history
…ed (#566)
  • Loading branch information
AllanZhengYP authored and trivikr committed Jan 3, 2020
1 parent 272ae8d commit 0454dd6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/config-resolver/src/EndpointsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ export interface EndpointsResolvedConfig
export function resolveEndpointsConfig<T>(
input: T & EndpointsInputConfig & PreviouslyResolved
): T & EndpointsResolvedConfig {
const tls = input.tls || true;
const tls = input.tls === undefined ? true : input.tls;
const endpoint: Provider<Endpoint> = input.endpoint
? normalizeEndpoint(input.endpoint, input.urlParser)
: () =>
input.region().then(async region => {
const hostname = (
(await input.regionInfoProvider(region)) || ({} as RegionInfo)
).hostname;
if (!hostname)
if (!hostname) {
throw new Error("Cannot resolve hostname from client config");
const endpoint = input.urlParser(hostname);
endpoint.protocol = tls ? "https:" : "http:";
}
const endpoint = input.urlParser(
`${tls ? "https:" : "http:"}//${hostname}`
);
return endpoint;
});
return {
Expand Down

0 comments on commit 0454dd6

Please sign in to comment.