nosdav / pastebin

NosDAV pastebin
https://nosdav.github.io/pastebin/
MIT License
8 stars 1 forks source link

Refactor updateDownloadLink function #13

Closed melvincarvalho closed 1 year ago

melvincarvalho commented 1 year ago

Current implementation:

updateDownloadLink() {
  const inputSlug = document.getElementById("file-name").value;
  const downloadLink = document.getElementById("download");

  let filename;

  filename = inputSlug;

  const path = getPath(serverUrl, userPublicKey, filename, mode);
  downloadLink.setAttribute("href", path);
}

Suggested improvement:

updateDownloadLink() {
  const filename = document.getElementById("file-name").value;
  const downloadLink = document.getElementById("download");
  const path = getPath(serverUrl, userPublicKey, filename, mode);
  downloadLink.setAttribute("href", path);
}

The suggested refactor removes unnecessary variable assignments, making the function more concise and easier to read.