@inframanufaktur/clean-urls

1.0.1 • Public • Published

@inframanufaktur/clean-urls

Utility to remove tracking parameters from an URL

Usage

Basic usage:

const removeParams = require("@inframanufaktur/clean-urls");

const cleaned = removeParams("https://www.test.com/?utm_source=test");
// --> 'https://www.test.com/'

Allow companies through an allowlist:

const removeParams = require("@inframanufaktur/clean-urls");

const cleaned = removeParams(
  "https://www.test.com/?utm_source=test&pk_campaign=test",
  ["Piwik"]
);
// --> 'https://www.test.com/?pk_campaign=test'

How it works

The package takes the string of an URL and converts it with new URL.

Since it uses new URL you can only use this with URLs that contain a protocol and a hostname. /about/?utm_source=test will not work.

The search parameters of the URLs are matched against the list in ./data/params.js. It it matches and the associated company is not present in your allowlist, the param gets removed.

Compatability

Needs Node >v10 as its uses new URL().

Readme

Keywords

Package Sidebar

Install

npm i @inframanufaktur/clean-urls

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

5.76 kB

Total Files

5

Last publish

Collaborators

  • ovl