A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/npm-package-arg below:

npm/npm-package-arg: Parse the things that can be arguments to `npm install`

Parses package name and specifier passed to commands like npm install or npm cache add, or as found in package.json dependency sections.

const assert = require("assert")
const npa = require("npm-package-arg")

// Pass in the descriptor, and it'll return an object
try {
  const parsed = npa("@bar/foo@1.2")
} catch (ex) {
  
}

const npa = require('npm-package-arg')

const result = npa(arg[, where])

Throws if the package name is invalid, a dist-tag is invalid or a URL's protocol is not supported.

const result = npa.resolve(name, spec[, where])

Throws if the package name is invalid, a dist-tag is invalid or a URL's protocol is not supported.

const purl = npa.toPurl(arg, reg)

Returns the purl (package URL) form of the given package name/spec.

Throws if the package name is invalid, or the supplied arg can't be resolved to a purl.

The objects that are returned by npm-package-arg contain the following keys:

TLDR: file: urls are NOT uri encoded.

Historically, npm would uri decode file package args, but did not do any uri encoding for the saveSpec. This meant that it generated incorrect saveSpecs for directories with characters that looked like encoded uri characters, and also that it could not parse directories with some unencoded uri characters (such as %).

In order to fix this, and to not break all existing versions of npm, this module now parses all file package args as not being uri encoded. And in order to not break all of the package.json files npm has made in the past, it also does not uri encode the saveSpec. This includes package args that start with file:. This does mean that npm file: package args are not RFC compliant, and making them so constitutes quite a breaking change.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4