timvisee / send

:mailbox_with_mail: Simple, private file sharing. Mirror of https://gitlab.com/timvisee/send

Home Page:https://send.vis.ee

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FeatureRequest] Custom `/download/` in url

thmmsn opened this issue · comments

Our Send installation is on domain https://send.a-very-very-long-domain-name.com/

Send url is https://send.a-very-very-long-domain-name.com/download/<some-long-code>/<long-code-again>

Request:

  • Change default /download/ to something else
  • Shorter url's

Example
https://send.a-very-very-long-domain-name.com/geE4xui

/download/ can be shortened to /d/. Sadly I don't have time at this moment to implement this. Someone else may give it a shot in a PR in the meantime.

The basic tasks would probably be:

  • Add a configuration option to use short download URLs
  • If short download URLs are enabled, show /d/ URLs in the client after uploading.
  • Redirect /d/ to /download/, or use the same route for it.

Note that the only thing that can be shortened is the /download/ part. The ID and secret included after it cannot be shortened due to security reasons; most notably the private key after the #.

Instead of changing URL I made some changes to copyDialog.js and utils.js to copy formated text.

copyDialog.js

    function copy(event) {
      event.stopPropagation();
      copyToClipboard(url,name);
      event.target.textContent = state.translate('copiedUrl');
      setTimeout(close, 1000);
    }

utils.js

function copyToClipboard(str_url,str_name) {
 navigator.clipboard.write([
   new ClipboardItem({
     'text/plain': new Blob([str_url], { type: 'text/plain' }),
     'text/html': new Blob(['<a href="' + str_url + '"">' + str_name + '</a>'], { type: 'text/html' })
   })
 ])
}

The custom text/html could be one of the environment variables in the docker-compose.yml file.