Install string-to-url into to your project via npm:
$ npm install string-to-url --save-devgetUrls -- will give the array of urls present in the string
getHTMLText -- return HTML text converting all links to anchor tags.
Pass options object with all required properties if needed ex: target, title. e.t.c
ex: { target: '__blank' }
example1
//somePage.js
import { getUrls } from 'string-to-url';
console.log(getUrls('abc www.google.com www.apple.com');output:
["http://www.google.com", "mailto:gmail@gmail.com"]example2
//somePage.js
import { getHTMLText } from 'string-to-url';
console.log(getHTMLText('abc www.google.com');output:
abc <a href="http://www.google.com">www.google.com</a>example3
//somePage.js
import { getHTMLText } from 'string-to-url';
console.log(getHTMLText('abc www.google.com', { target: '__blank' });output:
abc <a target="__blank" href="http://www.google.com">www.google.com</a>