Skip to content

Commit

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

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

export const getHTML = url =>
Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/Twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ cases(
url: 'https://twitter.com/foobar/status/123',
valid: true,
},
"status url having 'www' subdomain": {
url: 'https://www.twitter.com/foobar/status/123',
valid: true,
},
}
);

Expand Down

0 comments on commit 682a0ef

Please sign in to comment.