Socket
Socket
Sign inDemoInstall

packageurl-js

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    packageurl-js

JavaScript library to parse and build "purl" aka. package URLs. This is a microlibrary implementing the purl spec at https://github.com/package-url


Version published
Weekly downloads
255K
increased by6.9%
Maintainers
1
Install size
41.2 kB
Created
Weekly downloads
 

Readme

Source

packageurl-js

Installing:

To install packageurl-js in your project, simply run:

npm install packageurl-js

This command will download the packageurl-js npm package for use in your application.

Local Development:

Clone the packageurl-js repo and cd into the directory.

Then run:

npm install

Testing

To run the test suite:

npm test

Usage Examples

Import ES6 Module
import { PackageURL } from 'packageurl-js';
Import CommonJs Module
const { PackageURL } = require('packageurl-js');
Parsing from a string
const pkg = PackageURL.fromString('pkg:maven/org.springframework.integration/spring-integration-jms@5.5.5');
console.log(pkg);

=>

PackageURL {
  type: 'maven',
  name: 'spring-integration-jms',
  namespace: 'org.springframework.integration',
  version: '5.5.5',
  qualifiers: null,
  subpath: null
}
Constructing
const pkg = new PackageURL(
    'maven',
    'org.springframework.integration',
    'spring-integration-jms',
    '5.5.5',
    undefined,
    undefined);

console.log(pkg.toString());

=>

pkg:maven/org.springframework.integration/spring-integration-jms@5.5.5
Error Handling
try {
    PackageURL.fromString('not-a-purl');
} catch(ex) {
    console.error(ex.message);
}

=>

purl is missing the required "pkg" scheme component.

Keywords

FAQs

Last updated on 06 Nov 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc