@tryghost/mg-tinynews 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/json-to-html.js +14 -10
  2. package/package.json +2 -2
@@ -252,25 +252,29 @@ const jsonToHtml = (blocks) => {
252
252
  } else if (itemType === 'image') {
253
253
  html.push(EntryImage(block));
254
254
  } else if (itemType === 'embed') {
255
- if (block.link.includes('https://twitter.com')) {
255
+ const embedUrl = URL.parse(block.link);
256
+ const embedHost = embedUrl?.hostname ?? '';
257
+ const embedPath = embedUrl?.pathname ?? '';
258
+
259
+ if (embedHost === 'twitter.com') {
256
260
  html.push(EntryTwitterEmbed(block));
257
- } else if (block.link.includes('https://www.tiktok.com')) {
261
+ } else if (embedHost === 'www.tiktok.com') {
258
262
  html.push(EntryTikTokEmbed(block));
259
- } else if (block.link.includes('https://www.facebook.com')) {
263
+ } else if (embedHost === 'www.facebook.com') {
260
264
  html.push(EntryFacebookEmbed(block));
261
- } else if (block.link.includes('https://vimeo.com')) {
265
+ } else if (embedHost === 'vimeo.com') {
262
266
  html.push(EntryVimeoEmbed(block));
263
- } else if (block.link.includes('https://www.youtube.com') || block.link.includes('https://youtu.be')) {
267
+ } else if (embedHost === 'www.youtube.com' || embedHost === 'youtu.be') {
264
268
  html.push(EntryYoutubeEmbed(block));
265
- } else if (block.link.includes('https://podcasts.apple.com')) {
269
+ } else if (embedHost === 'podcasts.apple.com') {
266
270
  html.push(EntryApplePodcastsEmbed(block));
267
- } else if (block.link.includes('https://open.spotify.com/episode/') || block.link.includes('https://open.spotify.com/show/')) {
271
+ } else if (embedHost === 'open.spotify.com' && (embedPath.startsWith('/episode/') || embedPath.startsWith('/show/'))) {
268
272
  html.push(EntrySpotifyEmbed(block));
269
- } else if (block.link.includes('https://www.instagram.com/p/')) {
273
+ } else if (embedHost === 'www.instagram.com' && embedPath.startsWith('/p/')) {
270
274
  html.push(EntryInstagramPostEmbed(block));
271
- } else if (block.link.includes('https://www.instagram.com/reel/')) {
275
+ } else if (embedHost === 'www.instagram.com' && embedPath.startsWith('/reel/')) {
272
276
  html.push(EntryInstagramReelEmbed(block));
273
- } else if (block.link.includes('https://docs.google.com')) {
277
+ } else if (embedHost === 'docs.google.com') {
274
278
  html.push(EntryGoogleDocsEmbed(block));
275
279
  } else {
276
280
  // eslint-disable-next-line no-console
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-tinynews",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TryGhost/migrate.git",
@@ -25,7 +25,7 @@
25
25
  "@tryghost/string": "0.3.5",
26
26
  "sanitize-html": "2.17.5",
27
27
  "simple-dom": "1.4.0",
28
- "@tryghost/mg-utils": "0.11.0"
28
+ "@tryghost/mg-utils": "0.11.1"
29
29
  },
30
30
  "scripts": {
31
31
  "dev": "echo \"Implement me!\"",