Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@
/*
Convert '?_option=value' to
{
options: value
option: value
}
*/
var result = {};
Expand Down Expand Up @@ -1745,7 +1745,7 @@
providerOptionsValue = options.getProviderOptions(path, defaultValue);
}

// `_.` has top priority.
// `_key` has top priority.
var value = options.getProviderOptions(alternatePath, providerOptionsValue);

if (
Expand All @@ -1771,7 +1771,7 @@

const bits = path.split('.');

const alternatePath = path.replace(/^[^.]+\./, '_'); // "robot.prerender" -> "_.prerender"
const alternatePath = path.replace(/^[^.]+\./, '_'); // "robot.prerender" -> "_prerender"

// p1.
var value = options.getProviderOptions(alternatePath);
Expand Down
26 changes: 15 additions & 11 deletions lib/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,26 +416,30 @@ class HostAbortController {
}

const cookiesOptions = [
'Domain',
'Expires',
'HttpOnly',
'Max-Age',
'Partitioned',
'Path',
'Secure',
'SameSite',
'domain',
'expires',
'httponly',
'max-age',
'partitioned',
'path',
'secure',
'samesite',
];

// Keep cookie values verbatim: default decode/encode (decodeURIComponent/encodeURIComponent)
// corrupts base64 values containing '/', '+', '=' on round-trip.
const identity = v => v;

export function extendCookiesJar(uri, jar, headers) {
var cookiesValue = headers && headers['set-cookie'];
if (cookiesValue) {
var cookiesArray = Array.isArray(cookiesValue) ? cookiesValue : [cookiesValue];
try {
var cookies = cookiesArray.reduce((allCookies, cookieStr) => {
return { ...allCookies, ...parseCookie(cookieStr) };
return { ...allCookies, ...parseCookie(cookieStr, { decode: identity }) };
}, {});
// Filter cookies options.
cookies = Object.fromEntries(Object.entries(cookies).filter(([k,v]) => !cookiesOptions.includes(k)));
cookies = Object.fromEntries(Object.entries(cookies).filter(([k,v]) => !cookiesOptions.includes(k.toLowerCase())));
jar = jar || {};
jar = {...jar, ...cookies};
} catch(ex) {
Expand All @@ -448,7 +452,7 @@ export function extendCookiesJar(uri, jar, headers) {
export function setCookieFromJar(uri, headers, jar) {
if (jar) {
try{
var cookies = Object.entries(jar).map(([k,v]) => serializeCookie(k, v)).join('; ');
var cookies = Object.entries(jar).map(([k,v]) => serializeCookie(k, v, { encode: identity })).join('; ');
headers['Cookie'] = cookies;
} catch(ex) {
log('Error serialize cookie', uri, ex.message);
Expand Down
2 changes: 1 addition & 1 deletion views/debug.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
var baseAppUrl = <%- JSON.stringify(CONFIG.baseAppUrl) %>;
var REL_GROUPS = <%- JSON.stringify(CONFIG.REL_GROUPS) %>;
var DEBUG = <%= JSON.stringify(DEBUG) %>;
var QUERY = <%- JSON.stringify(QUERY) %>;
var QUERY = <%- JSON.stringify(QUERY).replace(/</g, '\\u003c') %>;
</script>
</head>
<body>
Expand Down
Loading