Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JavaScript implementation of the package url spec

License

NotificationsYou must be signed in to change notification settings

package-url/packageurl-js

Repository files navigation

Installing

To installpackageurl-js in your project, simply run:

npm install packageurl-js

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

Local Development

Clone thepackageurl-js repo andcd into the directory.

Then run:

npm install

Testing

To run the test suite:

npmtest

Usage Examples

Importing

As an ES6 module

import{PackageURL}from'packageurl-js'

As a CommonJS module

const{ PackageURL}=require('packageurl-js')

Parsing

constpurlStr='pkg:maven/org.springframework.integration/spring-integration-jms@5.5.5'console.log(PackageURL.fromString(purlStr))console.log(newPackageURL(...PackageURL.parseString(purlStr)))

will both log

PackageURL {    type: 'maven',    name: 'spring-integration-jms',    namespace: 'org.springframework.integration',    version: '5.5.5',    qualifiers: undefined,    subpath: undefined}

Constructing

constpkg=newPackageURL('maven','org.springframework.integration','spring-integration-jms','5.5.5')console.log(pkg.toString())

=>

pkg:maven/org.springframework.integration/spring-integration-jms@5.5.5

Error Handling

try{PackageURL.fromString('not-a-purl')}catch(e){console.error(e.message)}

=>

Invalid purl: missing required "pkg" scheme component

Helper Objects

Helpers for encoding, normalizing, and validating purl components and types canbe imported directly from the module or found on the PackageURL class as staticproperties.

import{PackageURL,PurlComponent,PurlType}from'packageurl-js'PurlComponent===PackageURL.Component// => truePurlType===PackageURL.Type// => true

PurlComponent

Contains the following properties each with their ownencode,normalize,andvalidate methods, e.g.PurlComponent.name.validate(nameStr):

  • type
  • namespace
  • name
  • version
  • qualifiers
  • qualifierKey
  • qualifierValue
  • subpath

PurlType

Contains the following properties each with their ownnormalize, andvalidatemethods, e.g.PurlType.npm.validate(purlObj):

  • alpm
  • apk
  • bitbucket
  • bitnami
  • composer
  • conan
  • cran
  • deb
  • github
  • gitlab
  • golang
  • hex
  • huggingface
  • luarocks
  • maven
  • mlflow
  • npm
  • oci
  • pub
  • pypi
  • qpkg
  • rpm
  • swift

About

JavaScript implementation of the package url spec

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors16


[8]ページ先頭

©2009-2025 Movatter.jp