Skip to content

Commit

Permalink
fix(CodePen): 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 021be7e commit 0f73a71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/CodePen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { URL } from 'url';
export const shouldTransform = url => {
const { host, pathname } = new URL(url);

return host === 'codepen.io' && pathname.includes('/pen/');
return (
(host === 'codepen.io' || host === 'www.codepen.io') &&
pathname.includes('/pen/')
);
};

export const getHTML = url => {
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/CodePen.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ cases(
url: 'https://codepen.io/team/codepen/pen/PNaGbb',
valid: true,
},
"Team Pen url having 'www' subdomain": {
url: 'https://www.codepen.io/team/codepen/pen/PNaGbb',
valid: true,
},
'User Pen url': {
url: 'https://codepen.io/chriscoyier/pen/owBwKM',
valid: true,
},
"User Pen url having 'www' subdomain": {
url: 'https://www.codepen.io/chriscoyier/pen/owBwKM',
valid: true,
},
}
);

Expand Down

0 comments on commit 0f73a71

Please sign in to comment.