INNER CODE UNIT · JavaScript
iframePrimaryDomain
presenta-software/presenta-lib · src/blocks/embed/index.js:4
const iframePrimaryDomain = str => {
if (!str) return ''
const reg = new RegExp('src="(.*)', 'gim')
const url = reg.exec(str)
const dom = url[1].match(/http(s?):\/\/([\w]+\.){1}([\w]+\.?)+/gim)
return dom && dom.length > 0 ? dom[0] : null
}
const embed = function (el, config) {
const presentMode = config._mode === 'present' || config._mode === 'print' || config.overrideMode
let iframe = null
if (config.url) {
iframe = `<iframe src="${config.url}"></iframe>`
}
if (config.code) {
iframe = config.code
}