I'm looking for an on the fly URL shortener much like how tweetdeck works. I have found many jQuery and general javascript plugins that take a url and run it through a shortening service such as bit.ly when a button is pressed. However, I have not been able to find one that does it on the fly. My first question is does this already exist someplace? Secondly, if it doesn't, then what would be the best way to recognize a URL that needs to be shortened inside a textbox? My thoughts:
- On onKeyUp of that text area run through the text looking for http
- If found grab the whole URL (how do I determine the end? could be period, comma, space, etc...)
- Make sure the URL isn't already a bit.ly URL
- Validate the URL (make a request and make sure the http response is not an error, does bit.ly already do this?)
- If valid, send the url to bit.ly's API and get the response
- Replace the long URL with the short URL in the text area.
Thoughts?