Commit 6efc4580 authored by Quoc Huy Nguyen Dinh's avatar Quoc Huy Nguyen Dinh
Browse files

Closes #108

- fix embedded player for 3speak
- update 3speak TLD
parent b76df4d3
......@@ -52,10 +52,10 @@ Episode
https://open.spotify.com/episode/523CYPCmCXdv8uBME5yzZ7?si=l2uwhVjERe21N86grg3ZEg
## threespeak direct html iframe markup
<iframe src="https://3speak.online/embed?v=threespeak/iaarkpvf"></iframe>
<iframe src="https://3speak.co/embed?v=threespeak/iaarkpvf"></iframe>
## threespeak iframe embedded from link
https://3speak.online/watch?v=threespeak/iaarkpvf
https://3speak.co/watsch?v=threespeak/iaarkpvf
## twitch direct html iframe markup
<iframe src="https://player.twitch.tv/?channel=tfue" frameborder="0" allowfullscreen="true" scrolling="no" height="378" width="620"></iframe>
......
......@@ -6,11 +6,11 @@ import React from 'react';
*/
const regex = {
// eslint-disable-next-line no-useless-escape
sanitize: /^https:\/\/3speak\.online\/embed\?v=([A-Za-z0-9_\-\/]+)(&.*)?$/,
sanitize: /^https:\/\/3speak\.(?:online|co)\/embed\?v=([A-Za-z0-9_\-\/]+)(&.*)?$/,
// eslint-disable-next-line no-useless-escape
main: /(?:https?:\/\/(?:(?:3speak\.online\/watch\?v=)|(?:3speak\.online\/embed\?v=)))([A-Za-z0-9_\-\/]+)(&.*)?/i,
main: /(?:https?:\/\/(?:(?:3speak\.(?:online|co)\/watch\?v=)|(?:3speak\.(?:online|co)\/embed\?v=)))([A-Za-z0-9_\-\/]+)(&.*)?/i,
// eslint-disable-next-line no-useless-escape
htmlReplacement: /<a href="(https?:\/\/3speak\.online\/watch\?v=([A-Za-z0-9_\-\/]+))".*<img.*?><\/a>/i,
htmlReplacement: /<a href="(https?:\/\/3speak\.(?:online|co)\/watch\?v=([A-Za-z0-9_\-\/]+))".*<img.*?><\/a>/i,
embedShorthand: /~~~ embed:(.*?)\/(.*?) threespeak ~~~/,
};
export default regex;
......@@ -34,7 +34,7 @@ export const sandboxConfig = {
* @returns {*}
*/
export function genIframeMd(idx, threespeakId, width, height) {
const url = `https://3speak.online/embed?v=${threespeakId}`;
const url = `https://3speak.co/embed?v=${threespeakId}`;
let sandbox = sandboxConfig.useSandbox;
if (sandbox) {
......@@ -72,7 +72,7 @@ export function genIframeMd(idx, threespeakId, width, height) {
/**
* Check if the iframe code in the post editor is to an allowed URL
* <iframe src="https://3speak.online/embed?v=threespeak/iaarkpvf"></iframe>
* <iframe src="https://3speak.co/embed?v=threespeak/iaarkpvf"></iframe>
* @param url
* @returns {boolean|*}
*/
......@@ -95,7 +95,7 @@ export function normalizeEmbedUrl(url) {
const match = url.match(regex.contentId);
if (match && match.length >= 2) {
return `https://3speak.online/embed?v=${match[1]}`;
return `https://3speak.co/embed?v=${match[1]}`;
}
return false;
......@@ -120,7 +120,7 @@ export function extractMetadata(data) {
fullId,
url,
canonical: url,
thumbnail: `https://img.3speakcontent.online/${id}/post.png`,
thumbnail: `https://img.3speakcontent.co/${id}/post.png`,
};
}
......@@ -154,7 +154,7 @@ export function embedNode(child, links, images) {
// So we are handling thumbnail URL extraction differently.
const match = data.match(regex.embedShorthand);
if (match && images) {
const imageUrl = `https://img.3speakcontent.online/${
const imageUrl = `https://img.3speakcontent.co/${
match[2]
}/post.png`;
images.add(imageUrl);
......
......@@ -281,33 +281,33 @@ describe('Performance', () => {
it('threespeak', () => {
match(
threespeakRegex.main,
'https://3speak.online/watch?v=artemislives/tvxkobat'
'https://3speak.co/watch?v=artemislives/tvxkobat'
);
match(
threespeakRegex.main,
'https://3speak.online/watch?v=artemislives/tvxkobat&jwsource=cl'
'https://3speak.co/watch?v=artemislives/tvxkobat&jwsource=cl'
);
match(
threespeakRegex.main,
'https://3speak.online/embed?v=artemislives/tvxkobat'
'https://3speak.co/embed?v=artemislives/tvxkobat'
);
});
it('threespeakId', () => {
match(
threespeakRegex.main,
'https://3speak.online/watch?v=artemislives/tvxkobat',
'https://3speak.co/watch?v=artemislives/tvxkobat',
'artemislives/tvxkobat',
1
);
match(
threespeakRegex.main,
'https://3speak.online/watch?v=artemislives/tvxkobat&jwsource=cl',
'https://3speak.co/watch?v=artemislives/tvxkobat&jwsource=cl',
'artemislives/tvxkobat',
1
);
match(
threespeakRegex.main,
'https://3speak.online/embed?v=artemislives/tvxkobat',
'https://3speak.co/embed?v=artemislives/tvxkobat',
'artemislives/tvxkobat',
1
);
......@@ -315,7 +315,7 @@ describe('Performance', () => {
it('threespeakImageLink', () => {
match(
threespeakRegex.htmlReplacement,
'<a href="https://3speak.online/watch?v=artemislives/tvxkobat" rel="noopener" title="This link will take you away from steemit.com" class="steem-keychain-checked"><img src="https://steemitimages.com/768x0/https://img.3speakcontent.online/tvxkobat/post.png"></a>'
'<a href="https://3speak.co/watch?v=artemislives/tvxkobat" rel="noopener" title="This link will take you away from steemit.com" class="steem-keychain-checked"><img src="https://steemitimages.com/768x0/https://img.3speakcontent.online/tvxkobat/post.png"></a>'
);
});
it('twitter', () => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment