Closed SSbit01 closed 2 months ago
I'm trying to do the same thing. Is there a way to force https://
instead of http://
?
I'm trying to do the same thing. Is there a way to force
https://
instead ofhttp://
?
I've finally figured it out. Just overriding the default function of linkify.normalize
:
const md = markdownit({
linkify: true,
});
md.linkify.normalize = function(match) {
if (!match.schema) {
match.url = "https://" + match.url;
} else if (match.schema === "mailto:" && !match.url.startsWith("mailto:")) {
match.url = "mailto:" + match.url;
}
}
I am using markdown-it with linkify-it. It works great, however, when linkify-it recognizes a link without the protocol specified, it inserts HTTP instead of HTTPS. For example: "google.com" -> "http://google.com"
Is there any way to change the default protocol used?