Transform URLs in strings to actual links. It will find valid links in the given string and create <a>
tags for it.
Internally, it uses this Regex to identify links.
This library is available through the npm registry.
NPM
$ npm -i solid-links
Yarn
$ yarn add solid-links
Start using it by importing the library first.
const Linkify = require('solid-links');
or
import Linkify from 'solid-links';
import Linkify from 'solid-links';
const TEST_STRING = `
Will match the following cases
http://www.foufos.gr
https://www.foufos.gr
http://foufos.gr
http://www.foufos.gr/kino
http://werer.gr
www.foufos.gr
www.mp3.com
www.t.co
http://t.co
http://www.t.co
https://www.t.co
www.aa.com
http://aa.com
http://www.aa.com
https://www.aa.com
Will NOT match the following
www.foufos
www.foufos-.gr
www.-foufos.gr
foufos.gr
http://www.foufos
http://foufos
www.mp3#.com
`;
export default function Sample() {
return (
<Linkify
text={TEST_STRING}
style="text-decoration: underline; color: blue;"
/>
);
}
- Prince Neil Cedrick Castro - Initial work
See also the list of contributors who participated in this project.