Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 16, 2020 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/b262a491a92d8c5572e9702dfbad25b9 to your computer and use it in GitHub Desktop.
Save parzibyte/b262a491a92d8c5572e9702dfbad25b9 to your computer and use it in GitHub Desktop.
const $quicklink = document.querySelector("#quicklink"),
$resultado = document.querySelector("#resultado");
$quicklink.addEventListener("change", () => {
$resultado.textContent = obtenerLink();
});
const obtenerLink = () => {
const valor = decodeURIComponent($quicklink.value);
if (!valor) return "";
const busqueda = "?s=";
const indice = valor.indexOf(busqueda);
if (indice === -1) return "";
return valor.substring(indice+busqueda.length, valor.length);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment