0
I made this code simple to encode urls, but I would like it to work only with url checking if the protocol and hostname are correct or if the magnetic link is correct:
http://www.exemplo.com/
https://www.exemplo.com/
http://exemplo.com/
https://exemplo.com/
magnet:?xt=urn:btih: //url magnético
function codificar() {
var valor = document.getElementById("teste").value;
var encode = window.btoa(valor);
document.getElementById("saida").innerHTML = encode;
}
<p>Clique no botão para codificar a url.</p>
<br>
<input style='width:152px;' type="text" id="teste" value="http://www.exemplo.com">
<button onclick="codificar()">CODIFICAR</button>
<br>
<br>
<textarea style='width:150px; resize: none;' id="saida"></textarea>
You want to check whether the
url
have the patterns you quoted?– Thiago Magalhães
Yes exactly that
– Mark Vaaz