@mjhls/mjh-framework 1.0.604-hamMagazine-v5 → 1.0.604-hamMagazine-v7
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/dist/cjs/Auth.js +7 -7
- package/dist/cjs/HamMagazine.js +16 -15
- package/dist/cjs/View.js +2 -2
- package/dist/cjs/getRelatedArticle.js +354 -5
- package/dist/cjs/index-bd6c9f56.js +211 -0
- package/dist/cjs/index.js +3 -4
- package/dist/esm/Auth.js +6 -6
- package/dist/esm/HamMagazine.js +16 -15
- package/dist/esm/View.js +2 -2
- package/dist/esm/getRelatedArticle.js +354 -5
- package/dist/esm/index-db3bb315.js +207 -0
- package/dist/esm/index.js +2 -3
- package/package.json +1 -1
package/dist/cjs/Auth.js
CHANGED
|
@@ -22,8 +22,8 @@ var asyncToGenerator = require('./asyncToGenerator-8e707718.js');
|
|
|
22
22
|
require('./_set-species-4458e975.js');
|
|
23
23
|
var reactBootstrap = require('react-bootstrap');
|
|
24
24
|
var util = require('./util-f2c1b65b.js');
|
|
25
|
+
var index$4 = require('./index-bd6c9f56.js');
|
|
25
26
|
var useSWR = _interopDefault(require('swr'));
|
|
26
|
-
var cookie = require('cookie');
|
|
27
27
|
var Local = _interopDefault(require('passport-local'));
|
|
28
28
|
var mysql = _interopDefault(require('mysql'));
|
|
29
29
|
|
|
@@ -1215,7 +1215,7 @@ var MAX_AGE = 60 * 60 * 8; // 8 hours
|
|
|
1215
1215
|
|
|
1216
1216
|
function setTokenCookie(res, token, eKey) {
|
|
1217
1217
|
var cookies_serailized = [];
|
|
1218
|
-
cookies_serailized.push(
|
|
1218
|
+
cookies_serailized.push(index$4.serialize_1(TOKEN_NAME, token, {
|
|
1219
1219
|
//maxAge: MAX_AGE, // we want login cookie to expire when browser
|
|
1220
1220
|
//expires: new Date(Date.now() + MAX_AGE * 1000),
|
|
1221
1221
|
//httpOnly: true,
|
|
@@ -1224,7 +1224,7 @@ function setTokenCookie(res, token, eKey) {
|
|
|
1224
1224
|
//sameSite: 'lax',
|
|
1225
1225
|
}));
|
|
1226
1226
|
|
|
1227
|
-
cookies_serailized.push(
|
|
1227
|
+
cookies_serailized.push(index$4.serialize_1('eKey', eKey, {
|
|
1228
1228
|
//maxAge: MAX_AGE, // we want login cookie to expire when browser
|
|
1229
1229
|
//expires: new Date(Date.now() + MAX_AGE * 1000),
|
|
1230
1230
|
//httpOnly: true,
|
|
@@ -1238,12 +1238,12 @@ function setTokenCookie(res, token, eKey) {
|
|
|
1238
1238
|
|
|
1239
1239
|
function removeTokenCookie(res) {
|
|
1240
1240
|
var cookies_serailized = [];
|
|
1241
|
-
cookies_serailized.push(
|
|
1241
|
+
cookies_serailized.push(index$4.serialize_1(TOKEN_NAME, '', {
|
|
1242
1242
|
maxAge: -1,
|
|
1243
1243
|
expires: new Date(Date.now() - MAX_AGE * 1000),
|
|
1244
1244
|
path: '/'
|
|
1245
1245
|
}));
|
|
1246
|
-
cookies_serailized.push(
|
|
1246
|
+
cookies_serailized.push(index$4.serialize_1('eKey', '', {
|
|
1247
1247
|
maxAge: -1,
|
|
1248
1248
|
expires: new Date(Date.now() - MAX_AGE * 1000),
|
|
1249
1249
|
path: '/'
|
|
@@ -1257,8 +1257,8 @@ function parseCookies(req) {
|
|
|
1257
1257
|
if (req.cookies) return req.cookies;
|
|
1258
1258
|
|
|
1259
1259
|
// For pages we do need to parse the cookies.
|
|
1260
|
-
var cookie
|
|
1261
|
-
return
|
|
1260
|
+
var cookie = req.headers ? req.headers.cookie : null;
|
|
1261
|
+
return index$4.parse_1(cookie || '');
|
|
1262
1262
|
}
|
|
1263
1263
|
|
|
1264
1264
|
function getTokenCookie(req) {
|
package/dist/cjs/HamMagazine.js
CHANGED
|
@@ -100,6 +100,11 @@ var HamMagazine = function HamMagazine(props) {
|
|
|
100
100
|
searchKey = _useState12[0],
|
|
101
101
|
setSearchKey = _useState12[1];
|
|
102
102
|
|
|
103
|
+
var _useState13 = React.useState(0),
|
|
104
|
+
_useState14 = slicedToArray._slicedToArray(_useState13, 2),
|
|
105
|
+
topHeight = _useState14[0],
|
|
106
|
+
setTopHeight = _useState14[1];
|
|
107
|
+
|
|
103
108
|
React.useEffect(function () {
|
|
104
109
|
// handling the top mast component
|
|
105
110
|
var topNavHeight = document.querySelector('.top-nav-secondary') && document.querySelector('.top-nav-secondary').offsetHeight;
|
|
@@ -155,18 +160,15 @@ var HamMagazine = function HamMagazine(props) {
|
|
|
155
160
|
React.useEffect(function () {
|
|
156
161
|
var navOffsetTop = document.getElementById('navbar-ham') && document.getElementById('navbar-ham').offsetTop;
|
|
157
162
|
var adSection = document.querySelector('.AD728x90');
|
|
163
|
+
var mastHeadHeight = document.querySelector('.nav-brands') && document.querySelector('.nav-brands').offsetHeight ? document.querySelector('.nav-brands').offsetHeight : 0;
|
|
164
|
+
setTopHeight(mastHeadHeight);
|
|
158
165
|
if (window.pageYOffset > navOffsetTop) {
|
|
159
166
|
if (navRef.current && navRef.current.style) {
|
|
160
167
|
topNavRef.current.style.paddingBottom = navRef.current.offsetHeight + 'px';
|
|
161
168
|
navRef.current.style.position = 'fixed';
|
|
162
|
-
navRef.current.style.top =
|
|
169
|
+
if (mastHeadHeight) navRef.current.style.top = mastHeadHeight + 'px';
|
|
163
170
|
navRef.current.style.width = '100%';
|
|
164
171
|
navRef.current.style.zIndex = '99999';
|
|
165
|
-
// // Making the search Sticky on scroll
|
|
166
|
-
// searchRef.current.style.position = 'fixed'
|
|
167
|
-
// searchRef.current.style.top = `${navRef.current.offsetHeight + 1}px`
|
|
168
|
-
// searchRef.current.style.zIndex = '99999'
|
|
169
|
-
// searchRef.current.style.width = '100%'
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
var stickyNav = window.addEventListener('scroll', function () {
|
|
@@ -177,17 +179,14 @@ var HamMagazine = function HamMagazine(props) {
|
|
|
177
179
|
navRef.current.style.top = 0;
|
|
178
180
|
navRef.current.style.width = '100%';
|
|
179
181
|
navRef.current.style.zIndex = '99999';
|
|
180
|
-
// // Making the search Sticky on scroll
|
|
181
|
-
// searchRef.current.style.position = 'fixed'
|
|
182
|
-
// searchRef.current.style.top = `${navRef.current.offsetHeight + 1}px`
|
|
183
|
-
// searchRef.current.style.zIndex = '99999'
|
|
184
|
-
// searchRef.current.style.width = '100%'
|
|
185
182
|
}
|
|
186
183
|
} else {
|
|
187
184
|
if (navRef.current && navRef.current.style) {
|
|
185
|
+
var _mastHeadHeight = document.querySelector('.nav-brands') && document.querySelector('.nav-brands').offsetHeight ? document.querySelector('.nav-brands').offsetHeight : 0;
|
|
186
|
+
|
|
188
187
|
topNavRef.current.style.paddingBottom = '0';
|
|
189
188
|
navRef.current.style.position = 'relative';
|
|
190
|
-
navRef.current.style.top = '';
|
|
189
|
+
if (_mastHeadHeight) navRef.current.style.top = _mastHeadHeight + 'px';
|
|
191
190
|
if (adSection) adSection.style.marginTop = '';
|
|
192
191
|
}
|
|
193
192
|
}
|
|
@@ -200,6 +199,8 @@ var HamMagazine = function HamMagazine(props) {
|
|
|
200
199
|
var trackScrolling = function trackScrolling() {
|
|
201
200
|
var offsetTop = navRef.current.getBoundingClientRect().top;
|
|
202
201
|
var navLinks = document.getElementById('nav-links');
|
|
202
|
+
var mastHeadHeight = document.querySelector('.nav-brands') && document.querySelector('.nav-brands').offsetHeight;
|
|
203
|
+
if (mastHeadHeight) offsetTop = offsetTop - mastHeadHeight;
|
|
203
204
|
if (offsetTop <= 0) {
|
|
204
205
|
setIsSticky(true);
|
|
205
206
|
navLinks.style.margin = 'auto';
|
|
@@ -469,7 +470,7 @@ var HamMagazine = function HamMagazine(props) {
|
|
|
469
470
|
),
|
|
470
471
|
React__default.createElement(
|
|
471
472
|
Navbar,
|
|
472
|
-
{ id: 'navbar-ham', variant: 'dark', expand: 'xl', bg: 'primary', ref: navRef, style: { width: '100%', display: 'flex' } },
|
|
473
|
+
{ id: 'navbar-ham', variant: 'dark', expand: 'xl', bg: 'primary', ref: navRef, style: { width: '100%', display: 'flex', top: topHeight } },
|
|
473
474
|
React__default.createElement(
|
|
474
475
|
Container,
|
|
475
476
|
{ className: 'mobile-nav' },
|
|
@@ -503,9 +504,9 @@ var HamMagazine = function HamMagazine(props) {
|
|
|
503
504
|
{ jsx: 'true' },
|
|
504
505
|
'\n @media screen and (max-width: 1199px) {\n .site-logo-wrapper {\n display: block !important;\n margin: auto;\n }\n .site-logo-wrapper img {\n object-fit: contain;\n max-height: 45px;\n }\n .nav-mobile-logo {\n display: none !important;\n }\n }\n @media screen and (max-width: 767px) {\n .site-logo-wrapper {\n padding-right: 10%;\n }\n }\n @media screen and (max-width: 420px) {\n .site-logo-wrapper img {\n max-width: 200px;\n }\n }\n '
|
|
505
506
|
)
|
|
506
|
-
)
|
|
507
|
-
socialSearchComponent('mobile')
|
|
507
|
+
)
|
|
508
508
|
),
|
|
509
|
+
socialSearchComponent('mobile'),
|
|
509
510
|
React__default.createElement(
|
|
510
511
|
'div',
|
|
511
512
|
{ className: 'hamburger-menu-list', style: { width: '100%', maxHeight: '80vh' } },
|
package/dist/cjs/View.js
CHANGED
|
@@ -56,9 +56,9 @@ var keys$1 = require('./keys-a586b7a0.js');
|
|
|
56
56
|
require('react-bootstrap/Dropdown');
|
|
57
57
|
var getKeywords = require('./getKeywords.js');
|
|
58
58
|
var getSeriesDetail = require('./getSeriesDetail.js');
|
|
59
|
-
require('
|
|
60
|
-
var getQuery = require('./getQuery.js');
|
|
59
|
+
require('./index-bd6c9f56.js');
|
|
61
60
|
var getRelatedArticle = require('./getRelatedArticle.js');
|
|
61
|
+
var getQuery = require('./getQuery.js');
|
|
62
62
|
var getTargeting = require('./getTargeting-5a0b8ee4.js');
|
|
63
63
|
var urlFor = require('./urlFor.js');
|
|
64
64
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./_commonjsHelpers-06173234.js');
|
|
3
|
+
var _commonjsHelpers = require('./_commonjsHelpers-06173234.js');
|
|
4
4
|
require('./_to-object-329a650b.js');
|
|
5
5
|
require('./core.get-iterator-method-41e87ec1.js');
|
|
6
6
|
require('./_library-dd23b178.js');
|
|
@@ -8,9 +8,358 @@ require('./_iter-detect-4d0352f8.js');
|
|
|
8
8
|
require('./web.dom.iterable-43c3e277.js');
|
|
9
9
|
var asyncToGenerator = require('./asyncToGenerator-8e707718.js');
|
|
10
10
|
require('./_set-species-4458e975.js');
|
|
11
|
-
var
|
|
11
|
+
var index$4 = require('./index-bd6c9f56.js');
|
|
12
12
|
var getQuery = require('./getQuery.js');
|
|
13
13
|
|
|
14
|
+
var defaultParseOptions = {
|
|
15
|
+
decodeValues: true,
|
|
16
|
+
map: false,
|
|
17
|
+
silent: false,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function isNonEmptyString(str) {
|
|
21
|
+
return typeof str === "string" && !!str.trim();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function parseString(setCookieValue, options) {
|
|
25
|
+
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
26
|
+
var nameValue = parts.shift().split("=");
|
|
27
|
+
var name = nameValue.shift();
|
|
28
|
+
var value = nameValue.join("="); // everything after the first =, joined by a "=" if there was more than one part
|
|
29
|
+
|
|
30
|
+
options = options
|
|
31
|
+
? Object.assign({}, defaultParseOptions, options)
|
|
32
|
+
: defaultParseOptions;
|
|
33
|
+
|
|
34
|
+
var cookie = {
|
|
35
|
+
name: name, // grab everything before the first =
|
|
36
|
+
value: options.decodeValues ? decodeURIComponent(value) : value, // decode cookie value
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
parts.forEach(function (part) {
|
|
40
|
+
var sides = part.split("=");
|
|
41
|
+
var key = sides.shift().trimLeft().toLowerCase();
|
|
42
|
+
var value = sides.join("=");
|
|
43
|
+
if (key === "expires") {
|
|
44
|
+
cookie.expires = new Date(value);
|
|
45
|
+
} else if (key === "max-age") {
|
|
46
|
+
cookie.maxAge = parseInt(value, 10);
|
|
47
|
+
} else if (key === "secure") {
|
|
48
|
+
cookie.secure = true;
|
|
49
|
+
} else if (key === "httponly") {
|
|
50
|
+
cookie.httpOnly = true;
|
|
51
|
+
} else if (key === "samesite") {
|
|
52
|
+
cookie.sameSite = value;
|
|
53
|
+
} else {
|
|
54
|
+
cookie[key] = value;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return cookie;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function parse(input, options) {
|
|
62
|
+
options = options
|
|
63
|
+
? Object.assign({}, defaultParseOptions, options)
|
|
64
|
+
: defaultParseOptions;
|
|
65
|
+
|
|
66
|
+
if (!input) {
|
|
67
|
+
if (!options.map) {
|
|
68
|
+
return [];
|
|
69
|
+
} else {
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (input.headers && input.headers["set-cookie"]) {
|
|
75
|
+
// fast-path for node.js (which automatically normalizes header names to lower-case
|
|
76
|
+
input = input.headers["set-cookie"];
|
|
77
|
+
} else if (input.headers) {
|
|
78
|
+
// slow-path for other environments - see #25
|
|
79
|
+
var sch =
|
|
80
|
+
input.headers[
|
|
81
|
+
Object.keys(input.headers).find(function (key) {
|
|
82
|
+
return key.toLowerCase() === "set-cookie";
|
|
83
|
+
})
|
|
84
|
+
];
|
|
85
|
+
// warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
|
|
86
|
+
if (!sch && input.headers.cookie && !options.silent) {
|
|
87
|
+
console.warn(
|
|
88
|
+
"Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
input = sch;
|
|
92
|
+
}
|
|
93
|
+
if (!Array.isArray(input)) {
|
|
94
|
+
input = [input];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
options = options
|
|
98
|
+
? Object.assign({}, defaultParseOptions, options)
|
|
99
|
+
: defaultParseOptions;
|
|
100
|
+
|
|
101
|
+
if (!options.map) {
|
|
102
|
+
return input.filter(isNonEmptyString).map(function (str) {
|
|
103
|
+
return parseString(str, options);
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
var cookies = {};
|
|
107
|
+
return input.filter(isNonEmptyString).reduce(function (cookies, str) {
|
|
108
|
+
var cookie = parseString(str, options);
|
|
109
|
+
cookies[cookie.name] = cookie;
|
|
110
|
+
return cookies;
|
|
111
|
+
}, cookies);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/*
|
|
116
|
+
Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
|
|
117
|
+
that are within a single set-cookie field-value, such as in the Expires portion.
|
|
118
|
+
|
|
119
|
+
This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
|
|
120
|
+
Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
|
|
121
|
+
React Native's fetch does this for *every* header, including set-cookie.
|
|
122
|
+
|
|
123
|
+
Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
|
|
124
|
+
Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
|
|
125
|
+
*/
|
|
126
|
+
function splitCookiesString(cookiesString) {
|
|
127
|
+
if (Array.isArray(cookiesString)) {
|
|
128
|
+
return cookiesString;
|
|
129
|
+
}
|
|
130
|
+
if (typeof cookiesString !== "string") {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var cookiesStrings = [];
|
|
135
|
+
var pos = 0;
|
|
136
|
+
var start;
|
|
137
|
+
var ch;
|
|
138
|
+
var lastComma;
|
|
139
|
+
var nextStart;
|
|
140
|
+
var cookiesSeparatorFound;
|
|
141
|
+
|
|
142
|
+
function skipWhitespace() {
|
|
143
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
|
144
|
+
pos += 1;
|
|
145
|
+
}
|
|
146
|
+
return pos < cookiesString.length;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function notSpecialChar() {
|
|
150
|
+
ch = cookiesString.charAt(pos);
|
|
151
|
+
|
|
152
|
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
while (pos < cookiesString.length) {
|
|
156
|
+
start = pos;
|
|
157
|
+
cookiesSeparatorFound = false;
|
|
158
|
+
|
|
159
|
+
while (skipWhitespace()) {
|
|
160
|
+
ch = cookiesString.charAt(pos);
|
|
161
|
+
if (ch === ",") {
|
|
162
|
+
// ',' is a cookie separator if we have later first '=', not ';' or ','
|
|
163
|
+
lastComma = pos;
|
|
164
|
+
pos += 1;
|
|
165
|
+
|
|
166
|
+
skipWhitespace();
|
|
167
|
+
nextStart = pos;
|
|
168
|
+
|
|
169
|
+
while (pos < cookiesString.length && notSpecialChar()) {
|
|
170
|
+
pos += 1;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// currently special character
|
|
174
|
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
175
|
+
// we found cookies separator
|
|
176
|
+
cookiesSeparatorFound = true;
|
|
177
|
+
// pos is inside the next cookie, so back up and return it.
|
|
178
|
+
pos = nextStart;
|
|
179
|
+
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
180
|
+
start = pos;
|
|
181
|
+
} else {
|
|
182
|
+
// in param ',' or param separator ';',
|
|
183
|
+
// we continue from that comma
|
|
184
|
+
pos = lastComma + 1;
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
pos += 1;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
|
192
|
+
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return cookiesStrings;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var setCookie = parse;
|
|
200
|
+
var parse_1 = parse;
|
|
201
|
+
var parseString_1 = parseString;
|
|
202
|
+
var splitCookiesString_1 = splitCookiesString;
|
|
203
|
+
setCookie.parse = parse_1;
|
|
204
|
+
setCookie.parseString = parseString_1;
|
|
205
|
+
setCookie.splitCookiesString = splitCookiesString_1;
|
|
206
|
+
|
|
207
|
+
var dist = _commonjsHelpers.createCommonjsModule(function (module, exports) {
|
|
208
|
+
var __assign = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__assign) || function () {
|
|
209
|
+
__assign = Object.assign || function(t) {
|
|
210
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
211
|
+
s = arguments[i];
|
|
212
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
213
|
+
t[p] = s[p];
|
|
214
|
+
}
|
|
215
|
+
return t;
|
|
216
|
+
};
|
|
217
|
+
return __assign.apply(this, arguments);
|
|
218
|
+
};
|
|
219
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
220
|
+
exports.destroyCookie = exports.setCookie = exports.parseCookies = void 0;
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
var isBrowser = function () { return typeof window !== 'undefined'; };
|
|
224
|
+
function hasSameProperties(a, b) {
|
|
225
|
+
var aProps = Object.getOwnPropertyNames(a);
|
|
226
|
+
var bProps = Object.getOwnPropertyNames(b);
|
|
227
|
+
if (aProps.length !== bProps.length) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
for (var i = 0; i < aProps.length; i++) {
|
|
231
|
+
var propName = aProps[i];
|
|
232
|
+
if (a[propName] !== b[propName]) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Compare the cookie and return true if the cookies has equivalent
|
|
240
|
+
* options and the cookies would be overwritten in the browser storage.
|
|
241
|
+
*
|
|
242
|
+
* @param a first Cookie for comparison
|
|
243
|
+
* @param b second Cookie for comparison
|
|
244
|
+
*/
|
|
245
|
+
function areCookiesEqual(a, b) {
|
|
246
|
+
var sameSiteSame = a.sameSite === b.sameSite;
|
|
247
|
+
if (typeof a.sameSite === 'string' && typeof b.sameSite === 'string') {
|
|
248
|
+
sameSiteSame = a.sameSite.toLowerCase() === b.sameSite.toLowerCase();
|
|
249
|
+
}
|
|
250
|
+
return (hasSameProperties(__assign(__assign({}, a), { sameSite: undefined }), __assign(__assign({}, b), { sameSite: undefined })) && sameSiteSame);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Create an instance of the Cookie interface
|
|
254
|
+
*
|
|
255
|
+
* @param name name of the Cookie
|
|
256
|
+
* @param value value of the Cookie
|
|
257
|
+
* @param options Cookie options
|
|
258
|
+
*/
|
|
259
|
+
function createCookie(name, value, options) {
|
|
260
|
+
var sameSite = options.sameSite;
|
|
261
|
+
if (sameSite === true) {
|
|
262
|
+
sameSite = 'strict';
|
|
263
|
+
}
|
|
264
|
+
if (sameSite === undefined || sameSite === false) {
|
|
265
|
+
sameSite = 'lax';
|
|
266
|
+
}
|
|
267
|
+
var cookieToSet = __assign(__assign({}, options), { sameSite: sameSite });
|
|
268
|
+
delete cookieToSet.encode;
|
|
269
|
+
return __assign({ name: name, value: value }, cookieToSet);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
*
|
|
273
|
+
* Parses cookies.
|
|
274
|
+
*
|
|
275
|
+
* @param ctx
|
|
276
|
+
* @param options
|
|
277
|
+
*/
|
|
278
|
+
function parseCookies(ctx, options) {
|
|
279
|
+
if (ctx && ctx.req && ctx.req.headers && ctx.req.headers.cookie) {
|
|
280
|
+
return index$4.cookie.parse(ctx.req.headers.cookie, options);
|
|
281
|
+
}
|
|
282
|
+
if (isBrowser()) {
|
|
283
|
+
return index$4.cookie.parse(document.cookie, options);
|
|
284
|
+
}
|
|
285
|
+
return {};
|
|
286
|
+
}
|
|
287
|
+
exports.parseCookies = parseCookies;
|
|
288
|
+
/**
|
|
289
|
+
*
|
|
290
|
+
* Sets a cookie.
|
|
291
|
+
*
|
|
292
|
+
* @param ctx
|
|
293
|
+
* @param name
|
|
294
|
+
* @param value
|
|
295
|
+
* @param options
|
|
296
|
+
*/
|
|
297
|
+
function setCookie$1(ctx, name, value, options) {
|
|
298
|
+
if (ctx && ctx.res && ctx.res.getHeader && ctx.res.setHeader) {
|
|
299
|
+
var cookies = ctx.res.getHeader('Set-Cookie') || [];
|
|
300
|
+
if (typeof cookies === 'string')
|
|
301
|
+
cookies = [cookies];
|
|
302
|
+
if (typeof cookies === 'number')
|
|
303
|
+
cookies = [];
|
|
304
|
+
var parsedCookies = setCookie.parse(cookies);
|
|
305
|
+
var cookiesToSet_1 = [];
|
|
306
|
+
parsedCookies.forEach(function (parsedCookie) {
|
|
307
|
+
if (!areCookiesEqual(parsedCookie, createCookie(name, value, options))) {
|
|
308
|
+
cookiesToSet_1.push(index$4.cookie.serialize(parsedCookie.name, parsedCookie.value, __assign({ encode: function (val) { return val; } }, parsedCookie)));
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
cookiesToSet_1.push(index$4.cookie.serialize(name, value, options));
|
|
312
|
+
if (!ctx.res.finished) {
|
|
313
|
+
ctx.res.setHeader('Set-Cookie', cookiesToSet_1);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (isBrowser()) {
|
|
317
|
+
if (options && options.httpOnly) {
|
|
318
|
+
throw new Error('Can not set a httpOnly cookie in the browser.');
|
|
319
|
+
}
|
|
320
|
+
document.cookie = index$4.cookie.serialize(name, value, options);
|
|
321
|
+
}
|
|
322
|
+
return {};
|
|
323
|
+
}
|
|
324
|
+
exports.setCookie = setCookie$1;
|
|
325
|
+
/**
|
|
326
|
+
*
|
|
327
|
+
* Destroys a cookie with a particular name.
|
|
328
|
+
*
|
|
329
|
+
* @param ctx
|
|
330
|
+
* @param name
|
|
331
|
+
* @param options
|
|
332
|
+
*/
|
|
333
|
+
function destroyCookie(ctx, name, options) {
|
|
334
|
+
var opts = __assign(__assign({}, (options || {})), { maxAge: -1 });
|
|
335
|
+
if (ctx && ctx.res && ctx.res.setHeader && ctx.res.getHeader) {
|
|
336
|
+
var cookies = ctx.res.getHeader('Set-Cookie') || [];
|
|
337
|
+
if (typeof cookies === 'string')
|
|
338
|
+
cookies = [cookies];
|
|
339
|
+
if (typeof cookies === 'number')
|
|
340
|
+
cookies = [];
|
|
341
|
+
cookies.push(index$4.cookie.serialize(name, '', opts));
|
|
342
|
+
ctx.res.setHeader('Set-Cookie', cookies);
|
|
343
|
+
}
|
|
344
|
+
if (isBrowser()) {
|
|
345
|
+
document.cookie = index$4.cookie.serialize(name, '', opts);
|
|
346
|
+
}
|
|
347
|
+
return {};
|
|
348
|
+
}
|
|
349
|
+
exports.destroyCookie = destroyCookie;
|
|
350
|
+
exports.default = {
|
|
351
|
+
set: setCookie$1,
|
|
352
|
+
get: parseCookies,
|
|
353
|
+
destroy: destroyCookie,
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
_commonjsHelpers.unwrapExports(dist);
|
|
359
|
+
var dist_1 = dist.destroyCookie;
|
|
360
|
+
var dist_2 = dist.setCookie;
|
|
361
|
+
var dist_3 = dist.parseCookies;
|
|
362
|
+
|
|
14
363
|
var _this = undefined;
|
|
15
364
|
|
|
16
365
|
var getRelatedArticle = function () {
|
|
@@ -63,13 +412,13 @@ var getRelatedArticle = function () {
|
|
|
63
412
|
conditions = '';
|
|
64
413
|
|
|
65
414
|
if (ctx && url) {
|
|
66
|
-
cookies =
|
|
415
|
+
cookies = dist_3(ctx);
|
|
67
416
|
prevSlugs = cookies['prevSlugs'];
|
|
68
417
|
|
|
69
418
|
if (!!prevSlugs) {
|
|
70
|
-
|
|
419
|
+
dist_2(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"', {});
|
|
71
420
|
conditions = '&& !(url.current in [' + prevSlugs + '])';
|
|
72
|
-
} else
|
|
421
|
+
} else dist_2(ctx, 'prevSlugs', '"' + url + '"', {});
|
|
73
422
|
}
|
|
74
423
|
relatedArticleQuery = getQuery('related', conditions, '', articleCount);
|
|
75
424
|
_context.next = 12;
|