packageurl-js
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -0,1 +1,5 @@ | ||
# 0.0.6 | ||
### Bug Fixes | ||
* Properly replace all underscore values for PyPI packages [#23](https://github.com/package-url/packageurl-js/issues/23) | ||
# 0.0.5 | ||
@@ -2,0 +6,0 @@ ### Changes |
{ | ||
"name": "packageurl-js", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "JavaScript library to parse and build \"purl\" aka. package URLs. This is a microlibrary implementing the purl spec at https://github.com/package-url", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,1 +24,71 @@ # packageurl-js | ||
``` | ||
### 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. | ||
``` |
@@ -60,3 +60,3 @@ /* | ||
_handlePyPi() { | ||
this.name = this.name.toLowerCase().replace('_', '-'); | ||
this.name = this.name.toLowerCase().replace(/_/g, '-'); | ||
} | ||
@@ -63,0 +63,0 @@ |
@@ -73,4 +73,4 @@ /* | ||
assert.strictEqual(purlMixedCasing.toString(), 'pkg:pypi/pyyaml@5.3.0'); | ||
const purlWithUnderscore = PackageURL.fromString('pkg:pypi/typing_extensions@1.0.0'); | ||
assert.strictEqual(purlWithUnderscore.toString(), 'pkg:pypi/typing-extensions@1.0.0'); | ||
const purlWithUnderscore = PackageURL.fromString('pkg:pypi/typing_extensions_blah@1.0.0'); | ||
assert.strictEqual(purlWithUnderscore.toString(), 'pkg:pypi/typing-extensions-blah@1.0.0'); | ||
}); | ||
@@ -77,0 +77,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31921
94