-
-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathquery-string-stripper.html
More file actions
143 lines (133 loc) · 4.19 KB
/
query-string-stripper.html
File metadata and controls
143 lines (133 loc) · 4.19 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Query String Stripper</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
h1 {
margin-bottom: 10px;
}
p {
margin-top: 0;
color: #666;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
#url-input {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
font-size: 16px;
margin-bottom: 20px;
}
#output-container {
display: none;
background-color: #f0f0f0;
padding: 15px;
border-radius: 5px;
margin-bottom: 15px;
}
#output-container.visible {
display: block;
}
#stripped-url {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
background-color: #fff;
font-size: 16px;
margin-bottom: 10px;
word-break: break-all;
}
#copy-button {
padding: 10px 20px;
cursor: pointer;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
}
#copy-button:hover {
background-color: #0056b3;
}
#copy-button:active {
background-color: #004085;
}
@media (max-width: 600px) {
body {
padding: 10px;
}
h1 {
font-size: 24px;
}
}
</style>
</head>
<body>
<h1>Query String Stripper</h1>
<p>Paste a URL to remove the query string (everything from ? onwards)</p>
<label for="url-input">URL:</label>
<input type="text" id="url-input" placeholder="https://example.com/page?param1=value1¶m2=value2">
<div id="output-container">
<label for="stripped-url">Stripped URL:</label>
<input type="text" id="stripped-url" readonly>
<button id="copy-button">Copy to clipboard</button>
</div>
<script>
const urlInput = document.getElementById('url-input');
const outputContainer = document.getElementById('output-container');
const strippedUrl = document.getElementById('stripped-url');
const copyButton = document.getElementById('copy-button');
function stripQueryString(url) {
const questionMarkIndex = url.indexOf('?');
if (questionMarkIndex === -1) {
return url;
}
return url.substring(0, questionMarkIndex);
}
urlInput.addEventListener('input', function() {
const inputValue = urlInput.value.trim();
if (inputValue) {
const stripped = stripQueryString(inputValue);
strippedUrl.value = stripped;
outputContainer.classList.add('visible');
} else {
outputContainer.classList.remove('visible');
}
});
copyButton.addEventListener('click', function() {
strippedUrl.select();
strippedUrl.setSelectionRange(0, 99999); // For mobile devices
navigator.clipboard.writeText(strippedUrl.value).then(() => {
const originalText = copyButton.textContent;
copyButton.textContent = 'Copied!';
setTimeout(() => {
copyButton.textContent = originalText;
}, 1500);
}).catch(() => {
// Fallback for older browsers
document.execCommand('copy');
const originalText = copyButton.textContent;
copyButton.textContent = 'Copied!';
setTimeout(() => {
copyButton.textContent = originalText;
}, 1500);
});
});
</script>
</body>
</html>