Question

So, i have an url - http://somesite.com/#sometext. I need to shorten this url with the bit.ly API. The problem is, i cant properly escape the '#' symbol. I dont get any short url's if trying to short this one with the API. But i can simply short any other url's (without the '#').

The thing is i can properly shorten this url on bit.ly website and in TweetDeck (they using the API too, right?). But i cant manage to shorten it with the API.

Some suggestions?

Thanks you.

Was it helpful?

Solution

You can escape the URL fragment (#something) before sending it to bit.ly for shortening. URL fragment by definition won't leave the browser when submitted to the server. Escaping it allows it to go through. E.g. in Javascript, escUrl = encodeURIComponent(url) would do it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top