🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

conservative-normalize-url

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conservative-normalize-url

Normalize URLs conservatively, taking into account old specs to avoid breaking things.

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
3
-62.5%
Maintainers
1
Weekly downloads
 
Created
Source

conservative-normalize-url

Normalize URLs conservatively, taking into account old specs to avoid breaking things.

Background

I created this library, because I was frustrated by the lack of backwards-compatibility of existing URL normalizers. If you're normalizing a URL, it's likely you're dealing with a user-supplied URL. After working on software that handles bookmarks for a long time, I realized quite how diverse those can be. This is what I'm using now.

What does it do?

  • path normalization (/foo//bar/../baz => /foo/baz; when the protocol is known)
  • url encoding non-ASCII characters and unprintable characters (including space)
  • sorting query parameters
  • punycode encoding domains
  • omitting ports if the port is the default port for the given protocol

What does it not do?

  • omitting trailing slashes in paths
  • omitting www.
  • omitting any query parameters
  • adding or changing the protocol
  • removing the auth portion of the URL
  • breaking URLs with use ; as a query parameter separator

Usage

const normalizeUrl = require('conservative-normalize-url')

normalizeUrl('HtTp://foobar.com/bla bla h/shake?this=Ăśppa&oppa=this') // http://foobar.com/bla%20bla%20h/shake?oppa=this&this=%C3%B6ppa

License

(c) Marcel Klehr MIT License

Keywords

url

FAQs

Package last updated on 28 May 2019

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