flaks-request 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flaks-request",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Lightweight lib for requests",
5
5
  "keywords": [
6
6
  "flaks",
@@ -120,10 +120,16 @@ function handleRequest(requestOptions, responseHandler) {
120
120
  const isHttps = url.startsWith("https://");
121
121
  parsed.port ??= (isHttps ? 443 : 80).toString();
122
122
 
123
+ if (requestOptions.search) {
124
+ const search = new URLSearchParams(requestOptions.search);
125
+ if (parsed.search.length) parsed.search += "&";
126
+
127
+ parsed.search += search.toString();
128
+ }
129
+
123
130
  /** @type {https.RequestOptions | http.RequestOptions} */
124
131
  const options = {
125
132
  ...requestOptions,
126
-
127
133
  protocol: parsed.protocol,
128
134
  hostname: parsed.hostname,
129
135
  path: parsed.pathname + parsed.search,
package/src/types.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { IncomingHttpHeaders, IncomingMessage } from "node:http";
2
2
 
3
- type SearchParamsValue = string | number | boolean | null | undefined | SearchParamsObject | unknown[];
3
+ /* type SearchParamsValue = string | number | boolean | null | undefined | SearchParamsObject | unknown[];
4
4
 
5
5
  export interface SearchParamsObject {
6
6
  [key: string]: SearchParamsValue;
7
- }
7
+ } */
8
8
 
9
9
  export interface RequestOptions {
10
10
  headers?: Record<string, string>;
11
- search?: SearchParamsObject;
11
+ search?: Record<string, string>;
12
12
  json?: unknown;
13
13
  method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
14
14
  path: string;
package/types/types.d.ts CHANGED
@@ -5,7 +5,7 @@ export interface SearchParamsObject {
5
5
  }
6
6
  export interface RequestOptions {
7
7
  headers?: Record<string, string>;
8
- search?: SearchParamsObject;
8
+ search?: Record<string, string>;
9
9
  json?: unknown;
10
10
  method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
11
11
  path: string;