Yup, but you’d still need a database since you need to store that lookup somewhere from long URL to short url.
What about using an IPFS key and using js-ipfs to look it up?
If I'm not mistaken. I think IPFS keys might also be too long. Since a shortcode is only 6 chars long.
Here's the website[1] I built with base64 encoding to share weblinks. I've been trying to think of a non-db approach, but haven't found one yet for link shortening.