Socket
Book a DemoInstallSign in
Socket

simple-url-shortener

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-url-shortener

A simple URL shortener without magic.

1.0.5
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

Simple URL Shortener

NPM Version

simple-url-shortener is a simple tool that build shorten urls for GitHub page without magic.

Here are steps:

  • Create shorten url mapping urls.json:
{
  "home": "https://liaoxuefeng.com",
  "BTC": "https://bitcoin.org"
}

The case-sensitive key is composed by 1 ~ 6 characters of a ~ z, A ~ Z and 0 ~ 9.

  • Create GitHub action build.yml (just copy the content and change the branch name if neccessary).

  • Set GitHub pages:

  • Settings - Pages - Build and deployment - Source: GitHub Actions;
  • Custom domain: set your custom domain and enable "Enforce HTTPS".

You can then access shorten URL like https://redirect.liaoxuefeng.com/BTC after build.

You can find the example repo.

Shorten URL

The urls.json contains key - url mapping. simple-url-shortener will generate HTML files for each shorten URL. The generated GitHub pages structure:

_site/
├── 404.html
├── index.html
├── BTC
│   └── index.html
└── home
    └── index.html

The HTML file uses <meta http-equiv="refresh" content="0;URL=xxx"/> for redirect:

$ curl https://redirect.liaoxuefeng.com/BTC/index.html
<html>
<head>
    <meta http-equiv="refresh" content="0;URL='https://bitcoin.org/'" />
    ...

Configuration

You can also set a config.json for configuration:

{
  "wait": 0, // auto redirect in seconds, 0 = immediately, n = display link and wait for n seconds, -1 = display link only.
  "generate404": true, // generate a 404 page, default to true.
  "generateIndex": true // generate an index page, default to true.
}

Customize

If you want to use your own designed template to generate pages, copy the following template files to your repo's root dir and make some change:

Keywords

shorten

FAQs

Package last updated on 09 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.