Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
domNode,
'attribs[data-gts-swapped-href]',
null
);
// replaces local links with element
if (
domNode.name === 'a' &&
!wasLinkProcessed &&
elementUrlNoProtocol.includes(wordPressUrlNoProtocol) &&
!elementUrlNoProtocol.includes(uploadsUrlNoProtocol)
) {
let url = urlParsed.path();
return (
{domToReact(domNode.children, parserOptions)}
);
}
// cleans up internal processing attribute
if (wasLinkProcessed) {
delete domNode.attribs['data-gts-swapped-href'];
}
// data passed from sourceParser
const fluidData =
domNode.name === 'img' &&
getByPath(domNode, 'attribs[data-gts-encfluid]', null);
if (fluidData) {
const fluidDataParsed = JSON.parse(fluidData);
replace: domNode => {
if (domNode.name === 'a' && domNode.attribs && domNode.attribs.href) {
return (
{domToReact(domNode.children)}
);
}
return null;
}
});
replace: (node) => {
if (node.name !== 'a' || node.type !== 'tag' || !node.children) return undefined;
const href = _.get(node, 'attribs.href');
if (!href) return undefined;
if (href.startsWith('/#def-')) {
const matches = href.match(/\/#def-(.*)/);
const docId = _.get(matches, '1');
if (!docId) return undefined;
return (
<a>{domToReact(node.children)}</a>
);
}
else if (href.startsWith('/#')) {
const matches = href.match(/\/#(.*)/);
const docId = _.get(matches, '1');
if (!docId) return undefined;
return (
<a>{domToReact(node.children)}</a>
);
}
},
});