/** * Copyright 2016 DanceDeets. * * @flow */ import * as React from 'react'; import Linkify from 'linkify-it'; import tlds from 'tlds'; import url from 'url'; import querystring from 'querystring'; import Helmet from 'react-helmet'; import ExecutionEnvironment from 'exenv'; const linkify = Linkify(); linkify.tlds(tlds); class OEmbed extends React.Component< { url: string, getOembedUrl: (pageUrl: string) => string, // eslint-disable-line react/no-unused-prop-types }, { embedCode: ?string, } > { constructor(props) { super(props); this.state = { embedCode: null, };
/* global URL */ const { isNumber, compact } = require('lodash'); const he = require('he'); const nodeUrl = require('url'); const LinkifyIt = require('linkify-it'); const linkify = LinkifyIt(); const { concatenateBytes, getViewOfArrayBuffer } = require('./crypto'); module.exports = { assembleChunks, findLinks, getChunkPattern, getDomain, getTitleMetaTag, getImageMetaTag, isLinkInWhitelist, isMediaLinkInWhitelist, isLinkSneaky, isStickerPack, }; const SUPPORTED_DOMAINS = [ 'youtube.com', 'www.youtube.com', 'm.youtube.com', 'youtu.be', 'reddit.com', 'www.reddit.com', 'm.reddit.com',
/* @flow */ import linkifyIt from 'linkify-it'; import tlds from 'tlds'; const linkify = linkifyIt(); linkify.tlds(tlds); // Gets all the links in the text, and returns them via the callback const linkStrategy = (contentBlock: Object, callback: Function) => { const links = linkify.match(contentBlock.get('text')); if (typeof links !== 'undefined' && links !== null) { for (let i = 0; i < links.length; i++) { callback(links[i].index, links[i].lastIndex); } } }; export default linkStrategy;