1.0.7 • Published 2 years ago

shortener-url-with-domain v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Link shortener with custom redirect How to use

Use the command npm or yarn for the button installation

NPM version

npm install --save shortener-url-with-domain

Or

yarn add shortener-url-with-domain

Example

note: CommonJsUsage

In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with require() use the following approach:

const { shortener } = require("shortener-url-with-domain");

Usage

the function shortener expects two parameters of which only the url is mandatory, by default it returns the shortened url with our domain name.

const { shortener } = require("shortener-url-with-domain");

/*
 * @params url = https://www.google.com
 * @return shortUrl = 01mz
 */
export const createUrl = async (url: string) => {
  let shortUrl = await shortener(url);
  return shortUrl;
};

or

If you want the clipped url to have your domain it would be:

const { shortener } = require("shortener-url-with-domain");

/*
 * @params url = https://www.google.com
 * @params domain = 'YOUR REDIRECT URI' -> Format : https://example.com/
 * @return shortUrl = https://example.com/01mz
 */
const createUrl = async (url: string) => {
  let shortUrl = await shortener(url);
  return shortUrl;
};

Mandatory Parameters

    url: string -> (required)
    domain: string -> (optional)

Usage Custom Redirect

In the path you indicated to the previous method you must send to the getUrl function only the shortUrl example:

const { getUrl } = require("shortener-url-with-domain");

Usage

const { getUrl } = require("shortener-url-with-domain");

/*
 * @params shortUrl = 01mz
 * @return url = https://google.com
 */
const returnUrl = async (shortUrl: string) => {
  let completeUrl = await getUrl(shortUrl);
  return completeUrl;
};
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago