Shorter URLs
Someone posted a Streamable link today and it reminded me of how short their URLs are. Is it possible to generate a 6-8 character long URL that redirects to the full URL without using third-party websites/services? Since you'd be redirecting to the long URLs, if you change your password not only would the original links fail to load anything now, so would the shorter URLs because they just redirect to the full URL.
I did find an open source service called Kutt and they have an API you can generate keys for. Now, that isn't really self hosted because you're relying on them to redirect the URL for you, but that might be an easier way of doing it? I just thought there could be a way to enable/disable short URLs when you load the docker image and then if you enable it, every time you copy a URL, it would generate a 6-8 digit URL and then whenever Clipface sees someone using that short URL, it redirects them to the real one in a browser.
It just looks a lot cleaner in a chat. I'll post a comparison below.
https://imgur.com/a/RsMrihs
EDIT: That imgur link just made me think of something, you could make it easy for Clipface to recognize a short URL by replacing the /watch/ part of a URL with something like /u/ or another letter. Like how imgur uses /a/. Right? I don't know. I really need to learn how to code. 😅
EDIT2: Actually, it wouldn't even have to be a starting argument on Docker. It could just be a button next to the other URL buttons: https://imgur.com/MCmzbr7
EDIT3: Now that I think about it, the URLs can't really be randomly generated. They'd have to be generated similarly to how you generate the public URLs.
The only challenge here is how to store the mapping between short IDs to the full path. Currently Clipface is completely stateless. It doesn't have a database and it doesn't maintain any internal cache. In order to map a short, random sequence of characters to a clip name, we need some kind of database (although it could just be a JSON file placed in the clip directory or something like that.)
Aside from that, I think this could be added without much complexity. There would need to be an unprotected API endpoint (for example /u/{id} as you suggested), and it would need to do a lookup in the aforementioned database for a matching ID. The simplest implementation would just map it to a path like /watch/My%20Clip%20Name.mkv?token=ABCDEFG12345.... The API endpoint could then return a HTTP 301 redirect to the browser, pointing it to the resolved path. Since the API endpoint is unprotected and will contain the public token it will effectively be a public link, and the same methods of invalidating the token will still work. (Changing user password or renaming the clip.)