Created
October 19, 2023 18:02
-
-
Save JayGoldberg/7a667d87b4a50ec26414d7c229d155f2 to your computer and use it in GitHub Desktop.
Strips all the parameters from URLs from one input field and populates the stripped URLs in the other
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>URL Parameter Stripper</title> | |
</head> | |
<body> | |
<h1>URL Parameter Stripper</h1> | |
<p>Enter one or more URLs in the field below, separated by newlines.</p> | |
<textarea id="urls" cols="80" rows="20" oninput="stripParams()"></textarea> | |
<div id="stripped-urls"></div> | |
<textarea id="stripped-urls-textarea" cols="80" rows="20"></textarea> | |
<script> | |
const stripParams = () => { | |
const urls = document.getElementById('urls').value.split('\n'); | |
const strippedUrls = urls.map(url => { | |
const urlParts = url.split('?'); | |
return urlParts[0]; | |
}); | |
<!-- document.getElementById('stripped-urls').innerHTML = strippedUrls.join('\n'); --> | |
document.getElementById('stripped-urls-textarea').value = strippedUrls.join('\n'); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment