parshap / html-linkify Goto Github PK
View Code? Open in Web Editor NEWTurn plain text links into safe HTML anchor elements
Turn plain text links into safe HTML anchor elements
The regex gets stuck in an infinite loop (JavaScript) when you have many trailing dots:
var text = 'http://www.google.com............................................';
linkify(text); // stuck in infinite loop
It is stuck here:
var rLink = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi;
...
while (match = rLink.exec(text)) { // stuck here
E.g. convert example.com
but not google.com
You should go to example.com
Learn more about it from this <a href="https://www.google.com/search?q=example.com">Google query</a>
When I run this over a text like <iframe src="https://player.vimeo.com/video/123123" ></iframe>
it'll kill the iframe.
https://videomail.io/[email protected]&subject=Question blahblah
ends up in a weird, broken link where the email address becomes another mailto link, but shouldn't.
Attributes are not being passed to the email render. ie.
{ attributes: { target: '_blank' }
Support with port?
e.g www.google.com:443
Currently the link regex only matches links that begin with "www" or "http://" ("or https://"). It may be warranted to consider other links. Possible approaches would be to look for other subdomains, look for other parts of a URI (e.g., a port), or whitelisting gTLDs. It would be useful to see what expectations are set by Twitter's, Facebook's and others' behaviors.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.