Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function modify(node, prop) {
const githubMaster = 'https://github.com/SAP/luigi/blob/master/';
if (has(node, prop)) {
var parsed = url.parse(node.properties[prop]);
if (
parsed.href.startsWith(githubMaster + 'docs') && parsed.pathname && parsed.pathname.endsWith('.md') ||
parsed.pathname && parsed.pathname.endsWith('.md')
) {
// internal link
// sample links: https://..., file.md, should not start with /file.md or ../file.md
node.properties['onclick'] = 'navigateInternal(event, this)';
node.properties['data-linktype'] = 'internal';
let newHref = parsed.href.replace(githubMaster + 'docs/', '').replace('.md', '');
// clean ./ from beginning of the link
if(newHref.startsWith('./')) {
newHref = newHref.substr(2);
}
visit(ast, 'element', node => {
if (is(node, headings) && has(node, 'id')) {
vFile.data.slugs.push({
depth: parseInt(node.tagName[1], 10) - 1,
value: toString(node),
heading: (node.properties as any)?.id,
});
}
});
} else {