1.1.12 • Published 20 hours ago

@layered/superurl v1.1.12

Weekly downloads
-
License
ISC
Repository
github
Last release
20 hours ago

🔗 superurl

superurl is a JavaScript library that can clean and extract info from URLs

Highlights

  • Removes tracking parameters
  • Adds protocol if missing, upgrades to https if domain requires it
  • Extracts infos (handle, IDs, usernames) from URLs without network requests

Getting Started

Installation

npm i @layered/superurl

Usage

const { sanitizeUrl, urlInfo } = require('@layered/superurl')

const cleanUrl = sanitizeUrl('example.com/path?utc_campaign=upgrade')
// returns https://example.com/path

const infos = sanitizeUrl('http://twitter.com/elonmusk')
// returns
{
	originalUrl: 'http://mobile.twitter.com/elonmusk',
	url: 'https://twitter.com/elonmusk',
	hostname: 'twitter.com',
	domain: 'twitter.com',
	subdomain: '',
	handle: 'elonmusk',
	providerId: null,
}

APIs

Sanitize URL

Sanitize/clean URL

sanitizeUrl(url: string | URL, options): string

  • url - URL to sanitize, can be string or URL. Ex: 'google.com'
  • options - Object of options to use, all optional: - allowedProtocols[] - What protocols are allowed for URL. Default: ['http:', 'https:']

URL info

Extract data from URL, without network requests.

urlInfo(url: string | URL, options): string

  • url - URL to check, can be string or URL. Ex: 'twitter.com/twitter'
  • options - Object of options to use, all optional: - allowedProtocols[] - What protocols are allowed for URL. Default: ['http:', 'https:']

More

Please report any issues here on GitHub. Any contributions are welcome

License

MIT

Copyright (c) Andrei Igna, Layered

1.1.12

20 hours ago

1.1.11

6 days ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.10

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago