-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
40 lines (39 loc) · 1.17 KB
/
index.html
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
<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Open Redirect Demo</title>
<script defer>
const u = new URL(location.href)
const searchParams = u.searchParams;
document.addEventListener("DOMContentLoaded", () => {
if (searchParams.has("redirect_to")) {
const redirectTo = searchParams.get("redirect_to");
if (confirm("Redirecting:" + redirectTo)) {
location.href = redirectTo
}
}
document.querySelector("input").addEventListener('input', (e) => {
const value = e.currentTarget.value
const a = document.querySelector("a")
if (value) {
const newUrl = new URL(location.href)
newUrl.searchParams.append("redirect_to", value)
a.href = newUrl.toString()
} else {
a.removeAttribute("href")
}
})
})
</script>
</head>
<body>
<label>
Redirect to:
<input type="text" />
</label>
<div>
<a>open</a>
</div>
</body>
</html>