fixed dtube videos

This commit is contained in:
u-e 2018-12-20 14:30:58 +03:00
parent 2b950da441
commit f1f827d1d4
2 changed files with 16 additions and 12 deletions

View File

@ -1,8 +1,6 @@
import React, { Component } from 'react';
import {
Image, TouchableOpacity, Text, View,
} from 'react-native';
// import FastImage from 'react-native-fast-image';
import { TouchableOpacity, Text, View } from 'react-native';
import FastImage from 'react-native-fast-image';
import { PostHeaderDescription } from '../../postElements';
import { PostDropdown } from '../../postDropdown';
import { Icon } from '../../icon';
@ -84,7 +82,7 @@ class PostCard extends Component {
onPress={() => this._handleOnContentPress()}
>
{!isHideImage && (
<Image source={_image} style={styles.image} defaultSource={DEFAULT_IMAGE} />
<FastImage source={_image} style={styles.image} defaultSource={DEFAULT_IMAGE} />
)}
<View style={[styles.postDescripton]}>
<Text style={styles.title}>{content.title}</Text>

View File

@ -34,10 +34,9 @@ export const markDown2Html = (input) => {
output = createYoutubeIframe(output);
}
// Has bug
// if (dTubeRegex.test(output)) {
// output = createDtubeIframe(output);
// }
if (dTubeRegex.test(output)) {
output = createDtubeIframe(output);
}
if (pullRightLeftRegex.test(output)) {
output = changePullRightLeft(output);
@ -145,10 +144,17 @@ const createYoutubeIframe = input => input.replace(youTubeRegex, (link) => {
const createDtubeIframe = input => input.replace(dTubeRegex, (link) => {
const execLink = dTubeRegex.exec(link);
const dTubeMatch = link.match(dTubeRegex)[0];
const embedLink = `https://emb.d.tube/#!/${execLink[2]}/${execLink[3]}`;
if (execLink[2] && execLink[3]) {
const embedLink = `https://emb.d.tube/#!/${execLink[2]}/${execLink[3]}`;
return iframeBody(embedLink);
return iframeBody(embedLink);
}
if (dTubeMatch) {
return iframeBody(dTubeMatch);
}
return link;
});
const createVimeoIframe = input => input.replace(vimeoRegex, (link) => {
@ -159,5 +165,5 @@ const createVimeoIframe = input => input.replace(vimeoRegex, (link) => {
return iframeBody(embedLink);
});
const iframeBody = link => `<iframe frameborder='0' src='${link}'></iframe>`;
const iframeBody = link => `<iframe frameborder='0' allowfullscreen src='${link}'></iframe>`;
const imageBody = link => `<img data-href="${link}" src="${link}">`;