class Purl::PackageURL

Overview

Represents a Package URL as defined by the purl specification (ECMA-427).

A Package URL is a URL string used to identify and locate a software package in a mostly universal and uniform way across programming languages.

Format: pkg:type/namespace/name@version?qualifiers#subpath

Example:

purl = Purl::PackageURL.new("npm", "@angular", "animation", "12.3.1")
purl.to_s # => "pkg:npm/%40angular/[email protected]"

Defined in:

purl/package_url.cr

Constant Summary

QUALIFIER_KEY_PATTERN = /^[a-z][a-z0-9._\-]*$/

Valid qualifier key pattern: starts with lowercase letter, contains only [a-z0-9._-]

SCHEME = "pkg"
TYPE_PATTERN = /^[a-zA-Z][a-zA-Z0-9.+\-]*$/

Valid type pattern: starts with letter, contains only [a-zA-Z0-9.+-]

Constructors

Instance Method Summary

Constructor Detail

def self.new(type : String, namespace : String | Nil, name : String, version : String | Nil = nil, qualifiers : Hash(String, String) | Nil = nil, subpath : String | Nil = nil) #

[View source]
def self.parse(purl_string : String) : PackageURL #

Parses a Package URL string and returns a PackageURL instance.


[View source]

Instance Method Detail

def ==(other : PackageURL) : Bool #

Equality comparison: two PackageURLs are equal if all normalized components match.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


[View source]
def name : String #

[View source]
def namespace : String | Nil #

[View source]
def qualifiers : Hash(String, String) | Nil #

[View source]
def subpath : String | Nil #

[View source]
def to_s(io : IO) : Nil #

Writes the Package URL in purl format directly to the given IO.


[View source]
def to_s : String #

Returns the Package URL as a string in the purl format.


[View source]
def type : String #

[View source]
def version : String | Nil #

[View source]