@ludo.ninja/components 2.3.68 → 2.3.69
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.
|
@@ -14,8 +14,12 @@ exports.hashString = hashString;
|
|
|
14
14
|
const withTimestampSSR = (getServerSideProps) => {
|
|
15
15
|
return async (context) => {
|
|
16
16
|
const now = Date.now();
|
|
17
|
-
const
|
|
18
|
-
const
|
|
17
|
+
const req = context.req;
|
|
18
|
+
const protocol = req.headers['x-forwarded-proto'] || 'http';
|
|
19
|
+
const host = req.headers.host;
|
|
20
|
+
const path = context.resolvedUrl;
|
|
21
|
+
const fullUrl = `${protocol}://${host}${path}`;
|
|
22
|
+
const hash = (0, exports.hashString)(fullUrl);
|
|
19
23
|
const secondsAgo = (hash % 59) + 2;
|
|
20
24
|
let proposedTimestamp = now - secondsAgo * 1000;
|
|
21
25
|
if (proposedTimestamp <= lastTimestamp) {
|
|
@@ -32,7 +36,7 @@ const withTimestampSSR = (getServerSideProps) => {
|
|
|
32
36
|
minute: '2-digit',
|
|
33
37
|
second: '2-digit',
|
|
34
38
|
});
|
|
35
|
-
const checksum = (0, exports.hashString)(
|
|
39
|
+
const checksum = (0, exports.hashString)(fullUrl + isoTimestamp);
|
|
36
40
|
if (getServerSideProps) {
|
|
37
41
|
const result = await getServerSideProps(context);
|
|
38
42
|
if ('props' in result) {
|
|
@@ -42,7 +46,7 @@ const withTimestampSSR = (getServerSideProps) => {
|
|
|
42
46
|
isoTimestamp,
|
|
43
47
|
displayTimestamp,
|
|
44
48
|
checksum,
|
|
45
|
-
currentUrl,
|
|
49
|
+
currentUrl: fullUrl,
|
|
46
50
|
},
|
|
47
51
|
};
|
|
48
52
|
}
|
|
@@ -53,7 +57,7 @@ const withTimestampSSR = (getServerSideProps) => {
|
|
|
53
57
|
isoTimestamp,
|
|
54
58
|
displayTimestamp,
|
|
55
59
|
checksum,
|
|
56
|
-
currentUrl,
|
|
60
|
+
currentUrl: fullUrl,
|
|
57
61
|
},
|
|
58
62
|
};
|
|
59
63
|
};
|