Extract all urls recognizing http / https from a string and returns an array of urls.
npm i extract-urls
yarn add extract-urls
<script src="https://unpkg.com/extract-urls@1.4.1/index.js"></script>
const extractUrls = require("extract-urls");
let text = `You can read https://github.com/huckbit/extract-urls or https://www.npmjs.com/package/extract-urls for more info`;
let urls = extractUrls(text);
console.log(urls);
//=> ['https://github.com/huckbit/extract-urls', 'https://www.npmjs.com/package/extract-urls']
To lowercase urls use the option true
:
let text = `You can read HTTPS://GITHUB.COM/HUCKBIT/EXTRACT-URLS or https://www.npmjs.com/package/extract-urls for more info`;
let urls = extractUrls(text, true);
//=> ['https://github.com/huckbit/extract-urls', 'https://www.npmjs.com/package/extract-urls']