Fix issue #93 - uses re to parse links in tweet #102
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this, the open {id} command was using only prefix-matching to parse links from tweets.
In old way, it used to split the tweet text and collected all the words with http/https as prefix.
As explained in a sample tweet in issue #93:
The parsed links here, will be 'http://darksky.net).' instead of 'http://darksky.net', which is wrong.
Now it uses regex module to parse the same.
As shortened URLs in tweets have 22/23 string length(based on protocol). So, all the short URLs have unique-id of length 10 as suffix.
So, a simple re.findall with https?://t.co/[a-zA-Z0-9]{10} as search pattern, will return a list of all the links in the tweet text.
That's it.