The `packageurl-js` library provides a JavaScript implementation for parsing, constructing, and validating Package URLs (purls) according to the official purl specification (https://github.com/package-url/purl-spec). Currently at version 2.0.1, it is a microlibrary focused solely on handling purl strings and objects. It offers a `PackageURL` class for object-oriented manipulation, static methods for string parsing, and helper objects like `PurlComponent` and `PurlType` for component-level validation and normalization. Its primary differentiator is strict adherence to the purl specification, ensuring consistent and correct handling of package identifiers across different ecosystems. Given its nature as a specification implementation, release cadence is typically driven by updates to the purl specification itself or critical bug fixes.
npm install packageurl-jsVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a Package URL string, constructing a `PackageURL` object programmatically, converting it back to a string, and robust error handling for invalid purl inputs.
Ensure all input strings strictly follow the purl specification (https://github.com/package-url/purl-spec). Always use `try...catch` blocks for robust error handling when processing external inputs.
Always use named imports: `import { PackageURL } from 'packageurl-js'` for ESM. For CommonJS, ensure destructuring: `const { PackageURL } = require('packageurl-js')`. Do not attempt `import PackageURL from 'packageurl-js'` or `const PackageURL = require('packageurl-js')` without destructuring.Verify that the input string is a well-formed PURL. Ensure it begins with 'pkg:' and follows the specified syntax for type, namespace, name, version, qualifiers, and subpath.
Correct your import statement. For ESM, use `import { PackageURL } from 'packageurl-js'`. For CommonJS, use `const { PackageURL } = require('packageurl-js')`.No dependency data recorded yet.