Bugfix
This commit is contained in:
+6
-2
@@ -1,5 +1,9 @@
|
||||
declare function _exports({ request }: {
|
||||
request: http.IncomingMessage;
|
||||
}): any | null;
|
||||
request?: http.IncomingMessage & {
|
||||
[x: string]: any;
|
||||
};
|
||||
}): {
|
||||
[x: string]: any;
|
||||
};
|
||||
export = _exports;
|
||||
import http = require("http");
|
||||
|
||||
@@ -16,22 +16,18 @@ const http = require("http");
|
||||
* @async
|
||||
*
|
||||
* @param {object} params - main params object
|
||||
* @param {http.IncomingMessage} params.request - HTTPS request object
|
||||
* @param {http.IncomingMessage & Object<string, any>} [params.request] - HTTPS request object
|
||||
*
|
||||
* @returns {any | null}
|
||||
* @returns {Object<string, any>}
|
||||
*/
|
||||
module.exports = function ({ request }) {
|
||||
/**
|
||||
* Check inputs
|
||||
*
|
||||
* @description Check inputs
|
||||
*/
|
||||
if (!request) return {};
|
||||
|
||||
/** @type {string | undefined} */
|
||||
const cookieString = request.headers.cookie;
|
||||
|
||||
if (!cookieString || typeof cookieString !== "string") {
|
||||
return null;
|
||||
return {};
|
||||
}
|
||||
|
||||
/** @type {string[]} */
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export = serializeQuery;
|
||||
declare function serializeQuery(param0: import("../types").SerializeQueryParams): string;
|
||||
@@ -0,0 +1,18 @@
|
||||
// @ts-check
|
||||
|
||||
/** @type {import("../types").SerializeQueryFnType} */
|
||||
function serializeQuery({ query }) {
|
||||
let str = "?";
|
||||
const keys = Object.keys(query);
|
||||
|
||||
/** @type {string[]} */
|
||||
const queryArr = [];
|
||||
keys.forEach((key) => {
|
||||
if (!key || !query[key]) return;
|
||||
queryArr.push(`${key}=${query[key]}`);
|
||||
});
|
||||
str += queryArr.join("&");
|
||||
return str;
|
||||
}
|
||||
|
||||
module.exports = serializeQuery;
|
||||
Reference in New Issue
Block a user