# Converting short upload URLs to full URLs

**URL:** <https://meta.discourse.org/t/converting-short-upload-urls-to-full-urls/131760>\
**Category:** Development\
**Created:** [October 23, 2019, 10:03pm UTC](https://meta.discourse.org/t/converting-short-upload-urls-to-full-urls/131760 "2019-10-23T22:03:12Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Sören\_Geier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/s%C3%B6ren_geier/32/235234_2.png) [@Sören\_Geier](https://meta.discourse.org/u/S%C3%B6ren_Geier)\
**Post date:** [May 13, 2022, 11:25am UTC](https://meta.discourse.org/t/converting-short-upload-urls-to-full-urls/131760/4 "2022-05-13T11:25:38Z")

</div>

Interesting. I am not able to reproduce this with Javascript. Because your last method is a binary2hex conversion but the outcome from the base62 decode is not a binary representation from what I understand.

From a JS perspective I found the following stuff helpful:  
[https://www.npmjs.com/package/aybabtu](https://www.npmjs.com/package/aybabtu)

```plaintext
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;
}

```

Unfortunately neither the bin2hex nor dec2hex methods help, when I use your input strings.

I created a codesandbox for that problem if someone is interested to play around with it. The final value is 1 for my input string which is wrong ;(

[https://codesandbox.io/s/kind-hypatia-dp5vh0?file=/src/index.js](https://codesandbox.io/s/kind-hypatia-dp5vh0?file=/src/index.js)

Thanks

---

_[View the full topic](https://meta.discourse.org/t/converting-short-upload-urls-to-full-urls/131760)._
