@ehtashamali/tinyurl
v2.1.0
Published
URL shortner module using http://tinyurl.com
Downloads
11
Maintainers
Readme
Node.js Module for tinyUrl
Getting Started
Built over TINYURL API
This module provides two functions: Shorten and Convert
Alnog with two Utill functions: extractHostname and extractRootDomain
Installation
Using npm:
npm i @ehtashamali/tinyurl
Example
let {
shorten,
convert,
extractHostname,
extractRootDomain
} = require("tiny-url");
//Without Alias
shorten("https://stackoverflow.com")
.then(link => {
//returns shorten url ex: tinyurl.com/adwa222
console.log("Short Url:", link);
})
.catch(error => console.log(error.message));
//With Alias
shorten("https://stackoverflow.com", "MyTestAlias")
.then(link => {
//returns shorten url ex: tinyurl.com/MyTestAlias
console.log("Short Url:", link);
})
.catch(error => console.log(error.message));
convert(link)
.then(result => {
//returns target url
console.log("Converted: ", result);
})
.catch(error => console.log(error.message));
extractHostname("https://stackoverflow.com")
.then(result => {
//returns stackoverflow.com
console.log("Hostname: ", result);
})
.catch(error => console.log(error.message));
extractRootDomain("https://stackoverflow.com")
.then(result => {
//returns stackoverflow.com
console.log("RootDomain: ", result);
})
.catch(error => console.log(error.message));
Built With
- http - HTTP
Contributing
Please read [CONTRIBUTING.md] under docs for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
I use SemVer for versioning. For the versions available, see the tags on this repository.
Author
- Ehtasham Ali
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details