Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

johan-perso/moreshort

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version française ici.

MoreShort

A library capable of shortening links through a simple function, using multiple services with short domain names.

Supported domains/services

rfrr.fr llui.site
is.gd v.gd
s.oriondev.fr liba.ro
s.3vm.cl s.erc.hr
s.585.eu s.jib.ar
s.ahpc.fi s.acme.si
s.coute.au s.fronturi.ro
shor.vercel.app

Installation

NodeJS

No support is guaranteed for old versions of NodeJS.

# With npm
npm i moreshort

# Or with pnpm
pnpm i moreshort
const moreshort = require('moreshort')

console.log(moreshort) // Returns information about the library
console.log(await moreshort.short('https://google.com')) // Returns a shortened link

Browser

<script src="https://cdn.jsdelivr.net/npm/moreshort/dist/browser.js"></script>
console.log(moreshort) // Returns information about the library
console.log(await moreshort.short('https://google.com')) // Returns a shortened link

In the browser, you can use the short function directly, without needing to use moreshort.short.

Using the main method

The main function has 3 arguments:

  • url : The URL to shorten (string)
  • provider : Domain name of the service to use (string)
  • You can get the list of available services with moreshort.servicesDomains

  • options :
    • shortcode : Short code to use (string)
    • Will be present in the shortened URL, after the slash (e.g. https://is.gd/shortcode)

    • Only some services support this feature; moreshort.servicesInfos has a boolean property shortcode for each service

    • replaceWhenErrors : Automatically replace the service used by another if an error occurs (boolean)

Example :

const moreshort = require('moreshort')

console.log(await moreshort.short('https://google.com')) // Shortened with a random service
console.log(await moreshort.short('https://google.com', 'is.gd')) // Shortened with the is.gd service
console.log(await moreshort.short('https://google.com', 'is.gd', { shortcode: 'google' })) // Shortened with the is.gd service and the short code "google"

License

MIT © Johan. Support this project if you want to help me 💙

About

A simple URL shortener module, using multiple services to shorten URLs

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.