Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 27f9f4d

Browse files
authored
Merge pull request #4680 from withspectrum/simplecast-embeds
Add support for simplecast urls to convert to embeds
2 parents 077a641 + 81e513c commit 27f9f4d

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

shared/draft-utils/add-embeds-to-draft-js.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const IFRAME_TAG = /<iframe.+?src=['"](.+?)['"]/gi;
99
const FRAMER_URLS = /\b((?:https?\/\/)?(?:www\.)?(?:framer\.cloud|share\.framerjs\.com)(\/[A-Za-z0-9\-\._~:\/\?#\[\]@!$&'\(\)\*\+,;\=]*)?)/gi;
1010
const CODEPEN_URLS = /\b(?:\/\/)?(?:www\.)?codepen\.io(\/[A-Za-z0-9\-\._~:\/\?#\[\]@!$&'\(\)\*\+,;\=]*)?/gi;
1111
const CODESANDBOX_URLS = /\b(?:\/\/)?(?:www\.)?codesandbox\.io(\/[A-Za-z0-9\-\._~:\/\?#\[\]@!$&'\(\)\*\+,;\=]*)?/gi;
12+
const SIMPLECAST_URLS = /\b(?:\/\/)?(?:www\.)?simplecast\.com(\/[A-Za-z0-9\-\._~:\/\?#\[\]@!$&'\(\)\*\+,;\=]*)?/gi;
1213

1314
type AddEmbedAttrs = {
1415
url: string,
@@ -145,5 +146,14 @@ export const getEmbedsFromText = (text: string): Array<AddEmbedAttrs> => {
145146
});
146147
});
147148

149+
match(SIMPLECAST_URLS, text).forEach(path => {
150+
embeds.push({
151+
url: `https://embed.simplecast.com/${path
152+
.replace('/s/', '')
153+
.replace('/', '')}`,
154+
height: 200,
155+
});
156+
});
157+
148158
return embeds;
149159
};

shared/draft-utils/test/add-embeds-to-draft-js.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,38 @@ describe('sites', () => {
259259
]);
260260
});
261261
});
262+
263+
describe('simplecast', () => {
264+
it('should handle simplecast urls', () => {
265+
const text = 'https://simplecast.com/s/8fb96767';
266+
expect(getEmbedsFromText(text)).toEqual([
267+
{
268+
height: 200,
269+
url: 'https://embed.simplecast.com/8fb96767',
270+
},
271+
]);
272+
});
273+
274+
it('should handle simplecast urls with query params', () => {
275+
const text = 'https://simplecast.com/s/8fb96767?color=000000';
276+
expect(getEmbedsFromText(text)).toEqual([
277+
{
278+
height: 200,
279+
url: 'https://embed.simplecast.com/8fb96767?color=000000',
280+
},
281+
]);
282+
});
283+
284+
it('should handle embed urls', () => {
285+
const text = 'https://embed.simplecast.com/8fb96767';
286+
expect(getEmbedsFromText(text)).toEqual([
287+
{
288+
height: 200,
289+
url: 'https://embed.simplecast.com/8fb96767',
290+
},
291+
]);
292+
});
293+
});
262294
});
263295

264296
describe('complex text', () => {

0 commit comments

Comments
 (0)