urlifyed
v1.0.2
Published
Extract links from sting and add anchor tags to it
Downloads
7
Maintainers
Readme
URLifyed
URLifyed is a lightweight npm package that simplifies the process of extracting URLs from plain text and converting them into clickable anchor tags. Whether you're working on a blog, chat application, or any other project, URLifyed has got you covered!
Installation
Install URLifyed using npm:
npm install urlifyed
Usage
- Import URLifyed into your project:
const urlifyed = require('urlifyed');
- Extract URLs from a string:
const inputText = 'Check out this awesome website: https://example.com and also visit https://another-site.org';
const extractedUrls = urlifyed.extractUrls(inputText);
console.log(extractedUrls);
//Output:
[
{ url: 'https://example.com', startIndex: 32, endIndex: 51 },
{ url: 'https://another-site.org', startIndex: 67, endIndex: 91 }
]
- Convert URLs to anchor tags:
const formattedText = urlifyed.formatWithAnchors(inputText);
console.log(formattedText);
// Output: 'Check out this awesome website: <a href="https://example.com">example.com</a> and also visit <a href="https://another-site.org">another-site.org</a>'