metrics-mvp icon indicating copy to clipboard operation
metrics-mvp copied to clipboard

Add URL shortening

Open hathix opened this issue 6 years ago • 2 comments

Our URLs for specific routes & trips are getting pretty long, e.g. "https://muni.opentransit.city/route/41/direction/41___I_F00/fromStop/6769/toStop/4102". This makes them unwieldy to copy/paste in Twitter, email, SMS, etc.

It'd be great if we could implement a simple URL shortener to make our URLs more shareable.

One simple idea is to create alternate routing that lets users use abbreviations. For instance, instead of this:

https://muni.opentransit.city/route/41/direction/41___I_F00/fromStop/6769/toStop/4102

users could share this:

https://muni.opentransit.city/r/41/d/I/f/6769/t/4102

or even

https://muni.opentransit.city/t/41/I/6769/4102

(the t/ at the start is to make sure no route number messes with our normal routing)

In other words, you want to losslessly compress the data encoded in the URL.

hathix avatar Oct 31 '19 04:10 hathix

I considered base64 encoding the string, but it wouldn't make the text any shorter.

The fancy alternative is to create a database that maps randomly-generated shortcodes to full URLs. This is how bit.ly and other "real" URL shorteners do it. But that's a lot of work to build and maintain.

hathix avatar Oct 31 '19 04:10 hathix

This is actually useful for things like #517, sharing links out

hathix avatar Feb 06 '20 02:02 hathix