blob: 940b1ee84585d9d1105535edb55ff7c7999c898a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function handleRequest(request, response) {
// Set cookies and redirect for .org:
if (request.host.endsWith(".org")) {
response.setHeader("Set-Cookie", "normalCookie=true; path=/;", true);
response.setHeader(
"Set-Cookie",
"laxHeader=true; path=/; SameSite=Lax",
true
);
response.setHeader(
"Set-Cookie",
"strictHeader=true; path=/; SameSite=Strict",
true
);
response.write(`
<head>
<meta http-equiv='set-cookie' content='laxMeta=true; path=/; SameSite=Lax'>
<meta http-equiv='set-cookie' content='strictMeta=true; path=/; SameSite=Strict'>
</head>
<body>
<script>
document.cookie = 'laxScript=true; path=/; SameSite=Lax';
document.cookie = 'strictScript=true; path=/; SameSite=Strict';
location.href = location.href.replace(/\.org/, ".com");
</script>
</body>`);
} else {
let baseURI =
"https://example.org/" +
request.path.replace(/[a-z-]*\.sjs/, "mimeme.sjs?type=");
response.write(`
<link rel="stylesheet" type="text/css" href="${baseURI}css">
<iframe src="${baseURI}html"></iframe>
<script src="${baseURI}js"></script>
<img src="${baseURI}png">
`);
}
}
|