https://github.com/pdkpavankumar/string-to-url
Utility to handle strings containing urls
https://github.com/pdkpavankumar/string-to-url
javascript linkify links nodejs string stringtouri url
Last synced: about 2 months ago
JSON representation
Utility to handle strings containing urls
- Host: GitHub
- URL: https://github.com/pdkpavankumar/string-to-url
- Owner: pdkpavankumar
- License: mit
- Created: 2019-03-26T15:32:01.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-22T21:04:55.000Z (about 6 years ago)
- Last Synced: 2025-09-26T04:51:25.730Z (9 months ago)
- Topics: javascript, linkify, links, nodejs, string, stringtouri, url
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# string-to-url
[](https://travis-ci.org/pdkpavankumar/string-to-url) [](https://david-dm.org/pdkpavankumar/string-to-url) [](https://david-dm.org/pdkpavankumar/string-to-url?type=dev) [](https://opensource.org/licenses/MIT)
## Installation
Install `string-to-url` into to your project via `npm`:
```shell
$ npm install string-to-url --save-dev
```
## Usage
getUrls -- 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
```js
//somePage.js
import { getUrls } from 'string-to-url';
console.log(getUrls('abc www.google.com www.apple.com');
```
output:
```sh
["http://www.google.com", "mailto:gmail@gmail.com"]
```
----
example2
```js
//somePage.js
import { getHTMLText } from 'string-to-url';
console.log(getHTMLText('abc www.google.com');
```
output:
```sh
abc www.google.com
```
----
example3
```js
//somePage.js
import { getHTMLText } from 'string-to-url';
console.log(getHTMLText('abc www.google.com', { target: '__blank' });
```
output:
```sh
abc www.google.com
```
----