Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const makeTransformImageUri = ({ repository }) => uri => {
// make sure to sanitize links through XSS-filter
let sanitizedUri = uriTransformer(uri);
// transform github relative links to images to absolute one to raw.githubusercontent.com
sanitizedUri = repository.isGithub
? buildImageUrl(repository, sanitizedUri)
: sanitizedUri;
return sanitizedUri;
};
const makeTransformLinkUri = ({ repository }) => uri => {
// make sure to sanitize links through XSS-filter
let sanitizedUri = uriTransformer(uri);
// transform github relative links to absolute ones
// keep the anchors - will be rendered by LinkRenderer
sanitizedUri =
repository.isGithub && !(uri && uri.startsWith("#"))
? buildLinkUrl(repository, sanitizedUri)
: sanitizedUri;
// transform links to npm to be used by our front router
return sanitizedUri
? sanitizedUri.replace(
/http[s]?:\/\/(www\.)?npmjs.com\/package\//,
"#/package/"
)
: null;
};
function transformLinkUri(uri: string): string {
if (!isAbsolutePath(uri) && props.metadata && props.metadata.path) {
const basePath = getPathDirname(props.metadata.path);
return ReactMarkdown.uriTransformer(
path.join(basePath, uri),
);
}
return ReactMarkdown.uriTransformer(uri);
}
const renderDocLink = ({ href, children }) => {
const uri = uriTransformer(href);
return <a> shell.openExternal(uri)} href="#">{children}</a>;
};
function transformLinkUri(uri: string): string {
if (!isAbsolutePath(uri) && props.metadata && props.metadata.path) {
const basePath = getPathDirname(props.metadata.path);
return ReactMarkdown.uriTransformer(
path.join(basePath, uri),
);
}
return ReactMarkdown.uriTransformer(uri);
}