dapplr.jsx 930 Bytes
Newer Older
Vishal Chandna's avatar
Vishal Chandna committed
1 2 3 4 5 6 7 8 9
/**
 * Regular expressions for detecting and validating provider URLs
 * @type {{htmlReplacement: RegExp, main: RegExp, sanitize: RegExp}}
 */
const regex = {
    sanitize: /^(https?:)?\/\/[a-z]*\.dapplr.in\/file\/dapplr-videos\/.*/i,
};
export default regex;

10 11 12 13 14 15
/**
 * Configuration for HTML iframe's `sandbox` attribute
 * @type {useSandbox: boolean, sandboxAttributes: string[]}
 */
export const sandboxConfig = {
    useSandbox: true,
16
    sandboxAttributes: ['allow-scripts', 'allow-same-origin', 'allow-popups'],
17 18
};

Vishal Chandna's avatar
Vishal Chandna committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32
/**
 * Check if the iframe code in the post editor is to an allowed URL
 * <iframe src="https://*.dapplr.in/file/dapplr-videos/" frameborder="0" allowfullscreen="true" scrolling="no" height="378" width="620"></iframe>
 * @param url
 * @returns {boolean|*}
 */
export function validateIframeUrl(url) {
    const match = url.match(regex.sanitize);
    if (match) {
        return url;
    }

    return false;
}