A Node.js wrapper for shortening and unshortening URLs.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE
.gitignore
README.md
index.js
package-lock.json
package.json

README.md

shortened

A Node.js wrapper for shortening and unshortening URLs.

installation

$ npm i shortened

docs

shorten

Shorten a full-sized URL! (currently only supports tinyurl)

const shortened = require('shortened');

shortened.shorten('https://google.com', function(res){
	console.log(res);
	// http://tinyurl.com/cucpjq
});

unshorten

Turn a shortened URL into a full-sized one! (uses the (unshorten.me)[https://unshorten.me/] API)

You can not give a URL with http:// or https:// in it, because of how the (unshorten.me)[https://unshorten.me/] API works. You will be given an error if you try to leave it in.

const shortened = require('shortened');

shortened.unshorten('tinyurl.com/cucpjq', function(res){
	console.log(res);
	// https://google.com
});

Now let me give you an example of what would happen if you were to leave in either the http:// or https://.

const shortened = require('shortened');

shortened.unshorten('https://tinyurl.com/cucpjq', function(res){
	console.log(res);
	// [shortened] ERROR! You shouldn't give shortened a url with https:// or http:// in it to unshorten. Try again without https:// or http:///
})