blob: 2cfae0d3987eb2887b90e5e4921c3b7d6c58788a (
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
|
function handleRequest(request, response) {
let params = new URLSearchParams(request.queryString);
let referrerPolicyHeader = params.get("header") || "";
let metaReferrerPolicy = params.get("meta") || "";
let showReferrer = params.has("show");
if (referrerPolicyHeader) {
response.setHeader("Referrer-Policy", referrerPolicyHeader, false);
}
let metaString = "";
let resultString = "";
if (metaReferrerPolicy) {
metaString = `<meta name="referrer" content="${metaReferrerPolicy}">`;
}
if (showReferrer) {
if (request.hasHeader("Referer")) {
resultString = `Referer Header: <a id="result">${request.getHeader(
"Referer"
)}</a>`;
} else {
resultString = `Referer Header: <a id="result"></a>`;
}
}
response.write(
`<!DOCTYPE HTML>
<html>
<head>
${metaString}
</head>
<body>
${resultString}
</body>
</html>`
);
}
|