Twitter – How to escape URLs in Twitter

twitter

I want to post a bit of script to Twitter which includes a URL. However, Twitter automatically sends URLs through its shortening service, with the (usually right, but in this case wrong) assumption that users would have wanted to do that anyway to save characters.

Is there any way to "escape" the URL so it doesn't get auto-shortened, but also so that the escape code doesn't get sent out as part of the tweet? The objective is to maintain the integrity of the script code in the tweet, such that all users (including those who may otherwise see a t.co link due to a faulty app or something) will see the code exactly as it is to be used in the script.

Best Answer

This won't completely avoid the URL shortening service, but it should generally serve the purpose of making what is displayed match what was written:

If the scripting language supports inline string concatenation, for the part where you need a URL, use that to break the domain name off from the rest of the URL.


Example

Instead of:

"http://foo.bar/qux.html"

use:

"http://"+"foo.bar"+"/qux.html"

or, if you can, just:

"foo.bar"+"/qux.html"

Twitter (and other clients which properly use Twitter's API) will still convert the domain to a hyperlink which targets a t.co URL. However, the hyperlink text should still just be the domain name as originally written.