Official link processing logic?


#1

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?

Thanks


#2

https://github.com/twitter?tab=repositories Did you checked the official Twitter text library? twitter-text-java is working correctly for me!


#3

Strange… this library I was using https://github.com/mikenz/twitter-text-php 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: https://twitter.com/RandomPod/status/334390175637577728

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