-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3653 - extract username correctly when there is a query #385
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,13 +51,19 @@ def stub_profile_lookup | |
match_one = Parser::TwitterProfile.match?('https://twitter.com/meedan') | ||
assert_equal true, match_one.is_a?(Parser::TwitterProfile) | ||
|
||
# Profile with query | ||
match_one = Parser::TwitterProfile.match?('https://twitter.com/meedan?ref_src=twsrc%5Etfw') | ||
assert_equal true, match_one.is_a?(Parser::TwitterProfile) | ||
|
||
# Mobile patterns | ||
match_two = Parser::TwitterProfile.match?('https://0.twitter.com/meedan') | ||
assert_equal true, match_two.is_a?(Parser::TwitterProfile) | ||
match_three = Parser::TwitterProfile.match?('https://m.twitter.com/meedan') | ||
assert_equal true, match_three.is_a?(Parser::TwitterProfile) | ||
match_four = Parser::TwitterProfile.match?('https://mobile.twitter.com/meedan') | ||
assert_equal true, match_four.is_a?(Parser::TwitterProfile) | ||
match_five = Parser::TwitterProfile.match?('https://mobile.twitter.com/meedan?ref_src=twsrc%5Etfw') | ||
|
||
assert_equal true, match_five.is_a?(Parser::TwitterProfile) | ||
end | ||
|
||
test "it makes a get request to the user lookup by username endpoint successfully" do | ||
|
@@ -193,4 +199,13 @@ def stub_profile_lookup | |
oembed_url = Parser::TwitterProfile.new('https://twitter.com/fake-account').oembed_url | ||
assert_equal 'https://publish.twitter.com/oembed?url=https://twitter.com/fake-account', oembed_url | ||
end | ||
|
||
test "should parse tweet profile with a query on the url" do | ||
stub_profile_lookup.returns(twitter_profile_response_success) | ||
|
||
data = Parser::TwitterProfile.new('https://www.twitter.com/fake_user?ref_src=twsrc%5Etfw').parse_data(empty_doc) | ||
|
||
assert_equal 'fake_user', data['external_id'] | ||
assert_equal '@fake_user', data['username'] | ||
end | ||
Comment on lines
+203
to
+210
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice test! |
||
end |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: These two regular expressions are still too broad and will keep matching things we don't want, right? But it can be a separate ticket, where we follow this: https://help.twitter.com/en/managing-your-account/twitter-username-rules#error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I kept it as it was from our previous twitter parser (that used v1.1). Anything that has twitter and isn't a tweet will match this one. Do we want to keep it this broad or make it more specific? If someone mistyped, e.g:
twitter.com/fake user
, it would still try to parse it as a twitter link (though, at this moment, it would fail)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it as is for now, and refine as we notice those cases (like we're handling in this ticket).