-
Notifications
You must be signed in to change notification settings - Fork 16
/
strictEncodeURL.html
32 lines (29 loc) · 1 KB
/
strictEncodeURL.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Strict URL Encode and Decode</title>
</head>
<body>
<script type="text/javascript">
function encode() {
thebox = document.getElementById("textbox");
thebox.value = encodeURI(thebox.value).replaceAll("%25", "%").replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
}
function decode() {
thebox = document.getElementById("textbox");
thebox.value = decodeURI(thebox.value);
}
function clearBox() {
thebox = document.getElementById("textbox");
thebox.value = "";
}
</script>
<h1>Strict URL Encode and Decode</h1>
<input type="text" class="out" id="textbox" value="" style="width:50%" />
<br><br>
<button onclick="encode();">Encode URL</button>
<button onclick="decode();">Decode URL</button>
<button onclick="clearBox();">Clear</button>
</body>
</html>