Official link processing logic?


Where can I obtain the logic being used by Twitter website to properly process tweet text URLs/hashtags/usernames/lists into links?

I tried using some PHP library (from github) but for example they included a trailing ‘!’ as part of a link, whereas Twitter correctly counts it out of the URL link.

I’m sure Twitter would (should?) share the whole extremely useful bit of info/logic, where might it be found?


#2 Did you checked the official Twitter text library? twitter-text-java is working correctly for me!


Strange… this library I was using looks an awful lot like that codebase, I wonder if they tried doing a PHP implementation but fell behind in conformance, or something.
An example tweet in question is this one:

That library 1) Doesn’t show the display URL, but rather the link text. And 2) it swallows the ‘!’ as part of the URL text as well as the actual href