gregjacobs / Autolinker.js

Utility to Automatically Link URLs, Email Addresses, Phone Numbers, Twitter handles, and Hashtags in a given block of text/HTML
MIT License
1.48k stars 238 forks source link

Wrong result when parsing CJK(中文/日文/韩文) char followed by colon #394

Open mercury233 opened 1 year ago

mercury233 commented 1 year ago
const Autolinker = require("autolinker")
const autolinker = new Autolinker({
    urls: {
        schemeMatches: true,
        tldMatches: false,
        ipV4Matches: false
    },
    newWindow: false,
    stripPrefix: false,
    email: false,
    phone: false,
    stripTrailingSlash: false
});

console.log(autolinker.link("链接:https://www.google.com"));
console.log(autolinker.link("link:https://www.google.com"));
console.log(autolinker.link("链接: https://www.google.com"));
console.log(autolinker.link("链接:https://www.google.com"));

image

https://runkit.com/embed/xpmv085le79y

The 4th result is wrong

keisukekomeda commented 1 year ago

Similar example here.

console.log(Autolinker.link("こちら→https://google.com"))
// result: こちら→https://g<a href="http://oogle.com" target="_blank" rel="noopener noreferrer">oogle.com</a>