The way that Twitter truncates their URL entity display_urls is causing an error at lib/twitter/base.rb:57, which uses the ::URI.parse method to parse the display_urls. This becomes a problem when printing out HTML versions of the tweets and using the entity location information given in the Tweet entity.
To see an example of this, pull tweet 381940500032258049 and check out the result. An example of this is shown at this gist.
According to the Twitter Entity docs, display_urls are "[n]ot a URL but a string to display instead of the media URL," so I don't think they should actually be parsed as URIs, but instead just made into strings.
This pull request contains a failing spec in the first commit. The second commit is a set of changes that makes display_uris into Strings, along with all the spec changes that that entails. It's a pretty heavy commit, so I don't know that it's the preferred way to go about it, but I wanted to give you an attempt at it.
Thanks for bringing this issue to my attention. I like what you’ve attempted here but the patch doesn’t apply cleanly to the master branch. Could you please pull down the latest master and rebase your changes so they can be merged without conflict?
Add failing spec for truncated display_urls.
Reclassify display_uris as Strings.
DRY up display_uri handling.
Coverage decreased (-35.84%) when pulling 9eacf39 on michaelherold:display-uri-issue into 6e0a09c on sferik:master.
Whoops, my bad. Always seem to forget a step.
I've rebased, so they should merge without trouble. I also DRYed up the way I made the fix by putting logic into the uri_attr_reader method instead of defining a mostly copy-and-paste display_uri_attr_reader method. Makes it so you don't have to remember the existence of a new method for uri attrs.
Add encoding to uri_spec for Ruby 1.9 compatibility.
Travis told me I forgot something else, so I had to set encoding on the uri_spec.rb file because of the unicode character in the sample display_url. Hopefully this fixes everything.
Coverage increased (+0.0%) when pulling 4dff29b on michaelherold:display-uri-issue into 6e0a09c on sferik:master.