Upgrade edge-runtime/cookies (#57124)
Backport fix on 13.5.6 to canary x-ref: #57021
This commit is contained in:
parent
6ad017d23f
commit
5d6592d895
4 changed files with 60 additions and 7 deletions
|
@ -137,7 +137,7 @@
|
|||
"@babel/traverse": "7.22.5",
|
||||
"@babel/types": "7.22.5",
|
||||
"@capsizecss/metrics": "1.1.0",
|
||||
"@edge-runtime/cookies": "4.0.1",
|
||||
"@edge-runtime/cookies": "4.0.2",
|
||||
"@edge-runtime/ponyfill": "2.4.1",
|
||||
"@edge-runtime/primitives": "4.0.2",
|
||||
"@hapi/accept": "5.0.2",
|
||||
|
|
|
@ -111,6 +111,57 @@ function parsePriority(string) {
|
|||
string = string.toLowerCase();
|
||||
return PRIORITY.includes(string) ? string : void 0;
|
||||
}
|
||||
function splitCookiesString(cookiesString) {
|
||||
if (!cookiesString)
|
||||
return [];
|
||||
var cookiesStrings = [];
|
||||
var pos = 0;
|
||||
var start;
|
||||
var ch;
|
||||
var lastComma;
|
||||
var nextStart;
|
||||
var cookiesSeparatorFound;
|
||||
function skipWhitespace() {
|
||||
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
||||
pos += 1;
|
||||
}
|
||||
return pos < cookiesString.length;
|
||||
}
|
||||
function notSpecialChar() {
|
||||
ch = cookiesString.charAt(pos);
|
||||
return ch !== "=" && ch !== ";" && ch !== ",";
|
||||
}
|
||||
while (pos < cookiesString.length) {
|
||||
start = pos;
|
||||
cookiesSeparatorFound = false;
|
||||
while (skipWhitespace()) {
|
||||
ch = cookiesString.charAt(pos);
|
||||
if (ch === ",") {
|
||||
lastComma = pos;
|
||||
pos += 1;
|
||||
skipWhitespace();
|
||||
nextStart = pos;
|
||||
while (pos < cookiesString.length && notSpecialChar()) {
|
||||
pos += 1;
|
||||
}
|
||||
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
||||
cookiesSeparatorFound = true;
|
||||
pos = nextStart;
|
||||
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
||||
start = pos;
|
||||
} else {
|
||||
pos = lastComma + 1;
|
||||
}
|
||||
} else {
|
||||
pos += 1;
|
||||
}
|
||||
}
|
||||
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
||||
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
||||
}
|
||||
}
|
||||
return cookiesStrings;
|
||||
}
|
||||
|
||||
// src/request-cookies.ts
|
||||
var RequestCookies = class {
|
||||
|
@ -196,8 +247,10 @@ var ResponseCookies = class {
|
|||
constructor(responseHeaders) {
|
||||
/** @internal */
|
||||
this._parsed = /* @__PURE__ */ new Map();
|
||||
var _a, _b, _c;
|
||||
this._headers = responseHeaders;
|
||||
const cookieStrings = responseHeaders.getSetCookie();
|
||||
const setCookie = (_c = (_b = (_a = responseHeaders.getSetCookie) == null ? void 0 : _a.call(responseHeaders)) != null ? _b : responseHeaders.get("set-cookie")) != null ? _c : [];
|
||||
const cookieStrings = Array.isArray(setCookie) ? setCookie : splitCookiesString(setCookie);
|
||||
for (const cookieString of cookieStrings) {
|
||||
const parsed = parseSetCookie(cookieString);
|
||||
if (parsed)
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"name":"@edge-runtime/cookies","version":"4.0.1","main":"./index.js","license":"MPL-2.0"}
|
||||
{"name":"@edge-runtime/cookies","version":"4.0.2","main":"./index.js","license":"MPL-2.0"}
|
||||
|
|
|
@ -896,8 +896,8 @@ importers:
|
|||
specifier: 1.1.0
|
||||
version: 1.1.0
|
||||
'@edge-runtime/cookies':
|
||||
specifier: 4.0.1
|
||||
version: 4.0.1
|
||||
specifier: 4.0.2
|
||||
version: 4.0.2
|
||||
'@edge-runtime/ponyfill':
|
||||
specifier: 2.4.1
|
||||
version: 2.4.1
|
||||
|
@ -3448,8 +3448,8 @@ packages:
|
|||
resolution: {integrity: sha512-smLocSfrt3s53H/XSVP3/1kP42oqvrkjUPtyaFd1F79ux24oE31BKt+q0c6lsa6hOYrFzsIwyc5GXAI5JmfOew==}
|
||||
dev: true
|
||||
|
||||
/@edge-runtime/cookies@4.0.1:
|
||||
resolution: {integrity: sha512-QIZ1lz6rAF8rTrFdGkljedUaZpXbGIWmRdbA+kwm15ddFfryyekYwI3luFKB33KDcXRHrBi6WdMuyQN19CS6pg==}
|
||||
/@edge-runtime/cookies@4.0.2:
|
||||
resolution: {integrity: sha512-BphVamVz/yt9FN1b60ZXp+iTJVRLUHI0POxKYZG3gn+RsP+M0phqS87Z9JnDn2YOsPx9SRhhrN9AB7yhpexNEw==}
|
||||
engines: {node: '>=16'}
|
||||
dev: true
|
||||
|
||||
|
|
Loading…
Reference in a new issue