links-finder
Small lib to find all links in a string and get their positions or wrap them with something(like html
<a>
tag)
Install library
npm install --save links-finder
or
yarn add links-finder
or
Download our minified version
or
Download our gziped version
Live demo
Take a look here
Examples of finding links
Default usage
; console; // will log [{start: 6, end: 20}]
Several links
; console; // will log [{start: 6, end: 20}, {start: 26, end: 38}]
No links
; console; // will log []
Links without http
; console; // will log [{start: 6, end: 17}] console; // will log [{start: 6, end: 13}]
Examples of wrapping links
in React way
Example of wrapping link with ; console; // will log 'magic <a href="http://blah.com"/>http://blah.com</a>'
Example of removing all links
; console; // will log 'magic '
Examples with tree shaking
; console; // will log [{start: 6, end: 20}]
; console; // will log 'magic <a href="http://blah.com"/>http://blah.com</a>'
test spec file
For more example, you can take a looks to ourThis lib is super fast and super tiny(< 6kb)
We support all modern browsers starting from IE9
Feel free to open ISSUES and create pull requests