GitHub
ESC

purl.cr

A Crystal implementation of the Package URL (purl) specification (ECMA-427). Parse, create, and manipulate Package URLs with type-safe Crystal code.

Implements the full ECMA-427 Package URL specification with type-specific normalization.

Overview

purl.cr provides a Crystal library for working with Package URLs -- a standardized format to identify and locate software packages across different ecosystems. It supports parsing purl strings, constructing new purls programmatically, and normalizing components per the specification.

Features

Installation

Add purl.cr to your shard.yml:

dependencies:
  purl:
    github: hahwul/purl.cr

Then run:

shards install

Quick Example

require "purl"

# Parse a Package URL string
purl = Purl::PackageURL.parse("pkg:npm/%40angular/animation@12.3.1")
puts purl.type      # => "npm"
puts purl.namespace  # => "@angular"
puts purl.name       # => "animation"
puts purl.version    # => "12.3.1"

# Create a Package URL from components
purl = Purl::PackageURL.new("pypi", nil, "Django", "4.2.0")
puts purl.to_s  # => "pkg:pypi/django@4.2.0"