From 5ea93ef052c66c814dabad9e20e820e7dd7f103c Mon Sep 17 00:00:00 2001 From: David Jones Date: Fri, 13 May 2022 10:07:55 +0200 Subject: [PATCH] Migrate from legacy querystringto URLSearchParams --- lib/request.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/request.ts b/lib/request.ts index aba685a..c54c175 100644 --- a/lib/request.ts +++ b/lib/request.ts @@ -4,11 +4,11 @@ import { request as httpRequest } from "http"; import { request as httpsRequest, RequestOptions } from "https"; -import * as querystring from "querystring"; import * as zlib from "zlib"; import { ServiceClientError } from "./client"; import { Socket } from "net"; import { Readable } from "stream"; +import { URLSearchParams } from "url"; const DEFAULT_READ_TIMEOUT = 2000; const DEFAULT_CONNECTION_TIMEOUT = 1000; @@ -53,7 +53,7 @@ interface Span { export interface ServiceClientRequestOptions extends RequestOptions { pathname: string; - query?: object; + query?: { [key: string]: string | string[] | undefined }; timing?: boolean; autoDecodeUtf8?: boolean; dropRequestAfter?: number; @@ -200,7 +200,7 @@ export const request = ( if ("pathname" in options && !("path" in options)) { if ("query" in options) { - let query = querystring.stringify(options.query); + let query = new URLSearchParams(options.query).toString(); if (query) { query = "?" + query; }