mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
16 lines
550 B
TypeScript
16 lines
550 B
TypeScript
// enable file link URLs in MarkdownIt. Keeps other URL restrictions of MarkdownIt untouched.
|
|
// Format [link name](file://...)
|
|
export default function(url: string) {
|
|
const BAD_PROTO_RE = /^(vbscript|javascript|data):/;
|
|
const GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/;
|
|
|
|
// url should be normalized at this point, and existing entities are decoded
|
|
const str = url.trim().toLowerCase();
|
|
|
|
if (str.indexOf('data:image/svg+xml,') === 0) {
|
|
return true;
|
|
}
|
|
|
|
return BAD_PROTO_RE.test(str) ? (GOOD_DATA_RE.test(str) ? true : false) : true;
|
|
}
|