npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

url-expander-tool

v0.0.4

Published

URL exctractor that support multiple services

Downloads

18

Readme

URL Expander Tool

Promise based URL expander for Node with multiple supported shorteners.

Core principles:

  1. Prefer API - Wherever possible use API provided by shortener services. This way, the best performance can be achieved (It might be about 3x faster then reading redirects).
  2. Expand only shorteners that are considered to be safe - Shorteners where people can earn money or hide sexually explicit websites will not be expanded but automatically marked as potentially harmful.

This expander can be best used for user generated content validation together with other tools.

Currently, these shorteners are supported:

  • Bit.ly - using API
  • Seomafia.net - using API
  • Is.gd - using API
  • Tiny.cc - using API
  • Tinyurl.com - using scrapping from tinyurl.com preview page

These shorteners are recognized:

  • potentially harmful: https://github.com/kozakvoj/url-expander/blob/master/resources/maliciousShorteners.json
  • considered to be safe: https://github.com/kozakvoj/url-expander/blob/master/resources/safeShorteners.json

Installing

Using npm:

npm install url-expander

Examples

Example 1

Create expand function with multiple shorteners. All other urls will return the same value.

const expander = require("url-expander-tool");

const bitly = expander.shorteners.bitly("INSERT_API_KEY");
const tinyurl = expander.shorteners.tinyurl();
const seomafia = expander.shorteners.seomafia();
const isgd = expander.shorteners.isgd();
const tinycc = expander.shorteners.tinyurl("INSERT_LOGIN", "INSET_API_KEY");

const expand = expander.createExpand([bitly, tinyurl, seomafia, isgd, tinycc]);

expand("http://bit.ly/gQUgaI"); // -> Promise -> http://bit.ly/bundles/kozakvoj/1
expand("https://tinyurl.com/ycc4x7hn"); // -> Promise -> https://www.vojtechkozak.cz;
expand("https://www.google.com"); // -> Promise -> https://www.google.com;

Example 2

Use only one shortener service.

const expander = require("url-expander-tool");

const bitly = expander.shorteners.bitly("INSERT_API_KEY");

bitly("http://bit.ly/gQUgaI"); // -> Promise -> http://www.vojtechkozak.cz

Testing

In order to test the expander, you have to crate a .env file inside /test directory. This file has to contain all API keys for the shortener services.

BITLY_API_KEY=
TINYCC_API_KEY=
TINYCC_API_LOGIN=

Then execute npm test.

Reference

  • bit.ly API reference: https://dev.bitly.com/links.html

  • seomafia.net API reference: http://seomafia.net/developer.html

  • is.gd API reference: https://is.gd/apishorteningreference.php

  • tiny.cc API reference: https://tiny.cc/api-docs