I may be barking up the wrong tree here, so apologies if I am - but any pointers very much welcome!
There are some threads in our Discourse site which are displayed in part on our main website. Because the cooked version of a post contains all the HTML for the lightbox, which we don’t want on the main site, I’m working with the raw version of a post.
One thing that’s tripping me up is the file upload URLs. How can I convert an upload:// URL to a full URL? I’ve tried searching and come across SHA1 and Base62, but apart from that, no matter what I try, I can’t get the full URL.
As I said, I may looking at the wrong thing, or there’s (likely) to be an easier way to these things, so any advice welcome!
function fromBase62(s) {
var digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var result = 0;
for (var i = 0; i < s.length; i++) {
var p = digits.indexOf(s[i]);
if (p < 0) {
return NaN;
}
result += p * Math.pow(digits.length, s.length - i - 1);
}
return result;
}