From f955534b3c5443b504af1624b5d5df753ffd3c5f Mon Sep 17 00:00:00 2001 From: uzlopak Date: Fri, 16 Aug 2024 21:38:05 +0200 Subject: [PATCH] chore: improve jsdoc in cookies --- lib/web/cookies/index.js | 18 ++++++++++-------- lib/web/cookies/parse.js | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/web/cookies/index.js b/lib/web/cookies/index.js index 323aa9ee6fb..d6657424527 100644 --- a/lib/web/cookies/index.js +++ b/lib/web/cookies/index.js @@ -9,14 +9,14 @@ const { Headers } = require('../fetch/headers') * @typedef {Object} Cookie * @property {string} name * @property {string} value - * @property {Date|number|undefined} expires - * @property {number|undefined} maxAge - * @property {string|undefined} domain - * @property {string|undefined} path - * @property {boolean|undefined} secure - * @property {boolean|undefined} httpOnly - * @property {'Strict'|'Lax'|'None'} sameSite - * @property {string[]} unparsed + * @property {Date|number} [expires] + * @property {number} [maxAge] + * @property {string} [domain] + * @property {string} [path] + * @property {boolean} [secure] + * @property {boolean} [httpOnly] + * @property {'Strict'|'Lax'|'None'} [sameSite] + * @property {string[]} [unparsed] */ /** @@ -29,6 +29,8 @@ function getCookies (headers) { webidl.brandCheck(headers, Headers, { strict: false }) const cookie = headers.get('cookie') + + /** @type {Record} */ const out = {} if (!cookie) { diff --git a/lib/web/cookies/parse.js b/lib/web/cookies/parse.js index 9fad27f713b..26dff025184 100644 --- a/lib/web/cookies/parse.js +++ b/lib/web/cookies/parse.js @@ -9,7 +9,7 @@ const assert = require('node:assert') * @description Parses the field-value attributes of a set-cookie header string. * @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4 * @param {string} header - * @returns if the header is invalid, null will be returned + * @returns {import('./index').Cookie|null} if the header is invalid, null will be returned */ function parseSetCookie (header) { // 1. If the set-cookie-string contains a %x00-08 / %x0A-1F / %x7F