Skip to content

Commit ec49986

Browse files
committed
remove deprecated parse()
1 parent b56bae9 commit ec49986

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/aws-cdk/lib/cli/telemetry/sink/endpoint-sink.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { IncomingMessage } from 'http';
22
import type { Agent } from 'https';
33
import { request } from 'https';
4-
import { parse, type UrlWithStringQuery } from 'url';
54
import { ToolkitError } from '@aws-cdk/toolkit-lib';
65
import { IoHelper } from '../../../api-private';
76
import type { IIoHost } from '../../io-host';
@@ -39,12 +38,12 @@ export interface EndpointTelemetrySinkProps {
3938
*/
4039
export class EndpointTelemetrySink implements ITelemetrySink {
4140
private events: TelemetrySchema[] = [];
42-
private endpoint: UrlWithStringQuery;
41+
private endpoint: URL;
4342
private ioHelper: IoHelper;
4443
private agent?: Agent;
4544

4645
public constructor(props: EndpointTelemetrySinkProps) {
47-
this.endpoint = parse(props.endpoint);
46+
this.endpoint = new URL(props.endpoint);
4847

4948
if (!this.endpoint.hostname || !this.endpoint.pathname) {
5049
throw new ToolkitError(`Telemetry Endpoint malformed. Received hostname: ${this.endpoint.hostname}, pathname: ${this.endpoint.pathname}`);
@@ -91,7 +90,7 @@ export class EndpointTelemetrySink implements ITelemetrySink {
9190
* Returns true if telemetry successfully posted, false otherwise.
9291
*/
9392
private async https(
94-
url: UrlWithStringQuery,
93+
url: URL,
9594
body: { events: TelemetrySchema[] },
9695
): Promise<boolean> {
9796
try {
@@ -117,15 +116,15 @@ export class EndpointTelemetrySink implements ITelemetrySink {
117116
* A Promisified version of `https.request()`
118117
*/
119118
function doRequest(
120-
url: UrlWithStringQuery,
119+
url: URL,
121120
data: { events: TelemetrySchema[] },
122121
agent?: Agent,
123122
) {
124123
return new Promise<IncomingMessage>((ok, ko) => {
125124
const payload: string = JSON.stringify(data);
126125
const req = request({
127126
hostname: url.hostname,
128-
port: url.port,
127+
port: url.port || null,
129128
path: url.pathname,
130129
method: 'POST',
131130
headers: {

0 commit comments

Comments
 (0)