Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assets.forEach((asset) => {
const assetPath = UIDLUtils.prefixAssetsPath(options.assetsPrefix, asset.path)
// link canonical for SEO
if (asset.type === 'canonical' && assetPath) {
const linkTag = createJSXTag('link')
addAttributeToJSXTag(linkTag, 'rel', 'canonical')
addAttributeToJSXTag(linkTag, 'href', assetPath)
addChildJSXTag(headNode, linkTag)
}
// link stylesheet (external css, font)
if ((asset.type === 'style' || asset.type === 'font') && assetPath) {
const linkTag = createJSXTag('link')
addAttributeToJSXTag(linkTag, 'rel', 'stylesheet')
addAttributeToJSXTag(linkTag, 'href', assetPath)
addChildJSXTag(headNode, linkTag)
}
assets.forEach((asset) => {
const assetPath = UIDLUtils.prefixAssetsPath(assetsPrefix, asset.path)
// link canonical for SEO
if (asset.type === 'canonical' && assetPath) {
const linkTag = HASTBuilers.createHTMLNode('link')
HASTUtils.addAttributeToNode(linkTag, 'rel', 'canonical')
HASTUtils.addAttributeToNode(linkTag, 'href', assetPath)
HASTUtils.addChildNode(headNode, linkTag)
}
// link stylesheet (external css, font)
if ((asset.type === 'style' || asset.type === 'font') && assetPath) {
const linkTag = HASTBuilers.createHTMLNode('link')
HASTUtils.addAttributeToNode(linkTag, 'rel', 'stylesheet')
HASTUtils.addAttributeToNode(linkTag, 'href', assetPath)
HASTUtils.addChildNode(headNode, linkTag)
}
const staticContent = styleValue.content
if (typeof staticContent === 'number') {
acc[styleKey] = styleValue
return acc
}
if (
typeof staticContent === 'string' &&
STYLE_PROPERTIES_WITH_URL.includes(styleKey) &&
staticContent.includes(Constants.ASSETS_IDENTIFIER)
) {
// split the string at the beginning of the ASSETS_IDENTIFIER string
const startIndex = staticContent.indexOf(Constants.ASSETS_IDENTIFIER) - 1 // account for the leading '/'
const newStyleValue =
staticContent.slice(0, startIndex) +
UIDLUtils.prefixAssetsPath(
assetsPrefix,
staticContent.slice(startIndex, staticContent.length)
)
acc[styleKey] = {
type: 'static',
content: newStyleValue,
}
} else {
acc[styleKey] = styleValue
}
return acc
case 'nested-style':
acc[styleKey] = styleValue
acc[styleKey].content = prefixAssetURLs(styleValue.content, assetsPrefix)
return acc
}
Object.keys(metaItem).forEach((key) => {
const metaValue = UIDLUtils.prefixAssetsPath(options.assetsPrefix, metaItem[key])
ASTUtils.addAttributeToJSXTag(metaTag, key, metaValue)
})
ASTUtils.addChildJSXTag(headNode, metaTag)
const icons = manifest.icons.map((icon) => {
const src = UIDLUtils.prefixAssetsPath(assetsPrefix || '', icon.src)
return { ...icon, src }
})
Object.keys(originalElement.attrs).forEach((attrKey) => {
const attrValue = originalElement.attrs[attrKey]
if (attrValue.type === 'static' && typeof attrValue.content === 'string') {
originalElement.attrs[attrKey].content = UIDLUtils.prefixAssetsPath(
assetsPrefix,
attrValue.content
)
}
})
}
Object.keys(metaItem).forEach((key) => {
const metaValue = UIDLUtils.prefixAssetsPath(options.assetsPrefix, metaItem[key])
ASTUtils.addAttributeToJSXTag(metaTag, key, metaValue)
})
ASTUtils.addChildJSXTag(headNode, metaTag)
Object.keys(metaItem).forEach((key) => {
const prefixedURL = UIDLUtils.prefixAssetsPath(assetsPrefix, metaItem[key])
HASTUtils.addAttributeToNode(metaTag, key, prefixedURL)
})
HASTUtils.addChildNode(headNode, metaTag)
Object.keys(tag).forEach((key) => {
tag[key] = UIDLUtils.prefixAssetsPath(options.assetsPrefix, tag[key])
})
})