Skip to content

Commit

Permalink
fix(Twitter): Only support twitter.com urls
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Oct 10, 2019
1 parent a8e44f2 commit 3c51a0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fetch from 'node-fetch';
export const shouldTransform = url => {
const { host, pathname } = new URL(url);

return host.endsWith('twitter.com') && pathname.includes('/status/');
return host === 'twitter.com' && pathname.includes('/status/');
};

export const getHTML = url =>
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/Twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ cases(
url: 'https://not-a-twitter-url.com',
valid: false,
},
"non-Twitter url ending with 'twitter.com'": {
url: 'https://this-is-not-twitter.com',
valid: false,
},
"non-Twitter url ending with 'twitter.com' and having '/status/'": {
url: 'https://this-is-not-twitter.com/foobar/status/123',
valid: false,
},
'profile url': {
url: 'https://twitter.com/MichaelDeBoey93',
valid: false,
Expand Down

0 comments on commit 3c51a0e

Please sign in to comment.