Socket
Book a DemoInstallSign in
Socket

safelinkify

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safelinkify

NodeJS anonymizer external links into outbound page. Anonymize external links to outbound page redirector for SEO.

latest
Source
npmnpm
Version
1.2.3
Version published
Weekly downloads
248
-9.82%
Maintainers
1
Weekly downloads
 
Created
Source

Safelinkify

npm version www.webmanajemen.com LICENSE GitHub language count Github Workflow GitHub forks GitHub stars

Customized safelink url redirector. Transform and Anonymize all hyperlinks to outbound pages. Useful for SEO external links and ADS.

  • API DOCUMENTATION
  • LIVE DEMO

Demo

pagesourcesamples
/page/safelink.htmlsafelink-decode.js
layout
template
compiler
/page/safelink.html?url=aHR0cHM6Ly...

Installation

Bundles

registrylinkcommands
npmhttps://www.npmjs.com/package/safelinkifynpm i safelinkify -D
githubhttps://github.com/dimaslanjaka/safelinknpm i https://github.com/dimaslanjaka/safelink -D
tarballhttps://github.com/dimaslanjaka/safelink/raw/master/release/safelinkify.tgznpm i https://github.com/dimaslanjaka/safelink/raw/master/release/safelinkify.tgz -D

npm

npm install safelinkify -D

Using yarn

yarn add safelinkify --dev

Development

git clone --single-branch --branch main https://github.com/dimaslanjaka/safelink foldername
cd foldername
yarn install # or npm install
CommandDescription
yarn startServe generated docs
yarn devWatch and build docs
yarn run docsBuild docs
yarn run buildBuild dist

Usage

Options

const options = {
  // Exclude patterns (do not anonymize these patterns)
  exclude: [
    'domain.com',
    /another.domain.com/,
    /https?:\/\/?([^*]+)\.)?webmanajemen\.com/,
    /([a-z0-9](?:[a-z0-9-]{1,61}[a-z0-9])?[.])*webmanajemen\.com/
  ],
  // URL redirector
  redirect: 'https://www.webmanajemen.com/page/safelink.html?url=',
  // Debug
  verbose: false,
  // Encryption type: 'base64' | 'aes'
  type: 'base64',
  // Password for AES (default: 'root')
  password: 'unique-password'
};

Browser

Script location: node_modules/safelinkify/dist/bundle.min.js

Include the script:

<script src="dist/bundle.min.js"></script>
<!-- or use CDN -->
<script src="https://raw.githack.com/dimaslanjaka/safelink/main/dist/bundle.min.js"></script>
<script src="https://cdn.statically.io/gh/dimaslanjaka/safelink/main/dist/bundle.min.js"></script>

Usage example:

<script>
  const sf = new safelink(options);
  // Automatically safelinkify all hyperlinks in body
  sf.parse(document.querySelector('body')).then((result) => {
    console.log(result);
    // In-page redirector
    sf.resolveQueryUrl(window.location.href);
  });
</script>

Node.js

Modern framework (vite,webpack,etc)

import * as safelink from 'safelinkify/browser_module';

const sf = new safelinkify.safelink(options);
const processedExternalLinks = sf.parse(`
<a href="www.example.com/page.php?id=xxxx&name=yyyy">external</a>
<a href="http://www.example.com/page.php?id=xxxx&name=yyyy">external</a>
<a href="https://www.example.com/page.php?id=xxxx&name=yyyy">external</a>
<a href="www.example.com/page.php/404"></a>
<a href="http://external.domain.com">internal</a>
<a href="http://www.webmanajemen.com">internal</a>
<a href="http://webmanajemen.com">internal</a>
<a href="#http://webmanajemen.com">#internal</a>
<a href="?http://webmanajemen.com">?internal</a>
<a href="">internal</a>
`);
processedExternalLinks.then(console.log);

Reference Examples

Import

const { safelink } = require('safelinkify');
// or
const { default: safelink } = require('safelinkify/dist/safelink');

Usage Example

import safelinkify from 'safelinkify';
// const safelinkify = require('safelinkify');
const sf = new safelinkify.safelink(options);
const processedExternalLinks = sf.parse(`
<a href="www.example.com/page.php?id=xxxx&name=yyyy">external</a>
<a href="http://www.example.com/page.php?id=xxxx&name=yyyy">external</a>
<a href="https://www.example.com/page.php?id=xxxx&name=yyyy">external</a>
<a href="www.example.com/page.php/404"></a>
<a href="http://external.domain.com">internal</a>
<a href="http://www.webmanajemen.com">internal</a>
<a href="http://webmanajemen.com">internal</a>
<a href="#http://webmanajemen.com">#internal</a>
<a href="?http://webmanajemen.com">?internal</a>
<a href="">internal</a>
`);
processedExternalLinks.then(console.log);

Result:

<a href="www.example.com/page.php?id=xxxx&name=yyyy">external</a>
<a href="https://www.webmanajemen.com/page/safelink.html?url=aHR0cDovL3d3dy5leGFtcGxlLmNvbS9wYWdlLnBocD9pZD14eHh4Jm5hbWU9eXl5eQ==">external</a>
<a href="https://www.webmanajemen.com/page/safelink.html?url=aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vcGFnZS5waHA/aWQ9eHh4eCZuYW1lPXl5eXk=">external</a>
<a href="www.example.com/page.php/404"></a>
<a href="http://external.domain.com">internal</a>
<a href="http://www.webmanajemen.com">internal</a>
<a href="http://webmanajemen.com">internal</a>
<a href="#http://webmanajemen.com">#internal</a>
<a href="?http://webmanajemen.com">?internal</a>
<a href="">internal</a>

Using Gulp

Reference: Gulp safelink task

import gulp from 'gulp';
import sf from 'safelinkify';
import { toUnix, join } from 'upath';
import through2 from 'through2';

const destDir = join(__dirname, 'build');

gulp.task('safelink', () => {
  const safelink = new sf.safelink({
    exclude: [
      /https?:\/\/?([^*]+)\.)?webmanajemen\.com/,
      /([a-z0-9](?:[a-z0-9-]{1,61}[a-z0-9])?[.])*webmanajemen\.com/
    ],
    redirect: 'https://www.webmanajemen.com/page/safelink.html?url=',
    verbose: false,
    type: 'base64',
    password: 'unique-password'
  });
  return gulp
    .src(['**/*.html'], {
      cwd: destDir,
      ignore: [
        '**/tmp/**',
        '**/node_modules/**',
        '**/monsters/**/*',
        '**/attendants/**/*',
        '**/materials/**/*',
        '**/scenic-spots/**/*',
        '**/static/**/*'
      ]
    })
    .pipe(
      through2.obj(async (file, _enc, next) => {
        if (file.isNull()) return next();
        const content = String(file.contents);
        const parsed = await safelink.parse(content);
        if (parsed) {
          file.contents = Buffer.from(parsed);
          next(null, file);
        } else {
          console.log('cannot parse', toUnix(file.path).replace(toUnix(process.cwd()), ''));
          next();
        }
      })
    )
    .pipe(gulp.dest(destDir));
});

Keywords

safelink

FAQs

Package last updated on 19 Jul 2025

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