Skip to content

Commit

Permalink
add shorts
Browse files Browse the repository at this point in the history
  • Loading branch information
feruzm committed Aug 10, 2024
1 parent 664d09b commit d94448d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/consts/regexes.const.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/consts/regexes.const.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/render-helper.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ecency/render-helper",
"version": "2.2.33",
"version": "2.2.34",
"description": "Markdown+Html Render helper",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/consts/regexes.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const INTERNAL_TOPIC_REGEX = /^\/(trending|hot|created|promoted|muted|pay
export const INTERNAL_POST_TAG_REGEX = /(.*)\/(@[\w.\d-]+)\/(.*)/i
export const INTERNAL_POST_REGEX = /^\/(@[\w.\d-]+)\/(.*)$/i
export const CUSTOM_COMMUNITY_REGEX = /^https?:\/\/(.*)\/c\/(hive-\d+)(.*)/i
export const YOUTUBE_REGEX = /(?:youtube.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu.be\/)([^"&?\/\s]{11})/g
export const YOUTUBE_REGEX = /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|shorts\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/g
export const YOUTUBE_EMBED_REGEX = /^(https?:)?\/\/www.youtube.com\/(embed|shorts)\/.*/i
export const VIMEO_REGEX = /(https?:\/\/)?(www\.)?(?:vimeo)\.com.*(?:videos|video|channels|)\/([\d]+)/i
export const VIMEO_EMBED_REGEX = /https:\/\/player\.vimeo\.com\/video\/([0-9]+)/
Expand Down
12 changes: 12 additions & 0 deletions src/markdown-2-html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,18 @@ describe('Markdown2Html', () => {

expect(markdown2Html(input, false)).toBe(expected)
})

it('70- Should handle youtube shorts/videos', () => {
const input = {
author: 'foo370',
permlink: 'bar370',
last_update: '2019-05-10T09:15:21',
body: 'https://www.youtube.com/shorts/IaehbZnsi4w'
}
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-youtube" data-embed-src="https://www.youtube.com/embed/IaehbZnsi4w?autoplay=1" data-youtube="IaehbZnsi4w"><img class="no-replace video-thumbnail" src="https://images.ecency.com/p/S5Eokt4BcQdk7EHeT1aYjzebg2hC7hkthT45e5VviwaTq13pYBZesC7Hh3idYK26Q1RMUHU.png?format=match&amp;mode=fit" /><span class="markdown-video-play"></span></a></p>'

expect(markdown2Html(input)).toBe(expected)
})
})

describe("Rumble support", () => {
Expand Down

0 comments on commit d94448d

Please sign in to comment.