Expand description
Package URL (ECMA-427) parsing and canonical form, for comparison only.
Experimental: may change in a 0.x minor release.
TEA asks a client to use a TEI “exactly as received” and to send the purl
query parameter as the caller’s “logical PURL string”. So nothing in this
SDK rewrites a PURL it sends, stores, locks or prints as the server’s. This
module exists so a caller can ask whether two PURLs name the same package:
Purl keeps the text it was parsed from (Purl::as_str), and the
canonical form is a separate type, CanonicalPurl, that cannot be passed
where a Purl is expected.
The rules ECMA-427 gives for every type are always applied
(PurlRules::Generic): lowercase scheme, type and qualifier keys;
percent-encoding normalized; empty qualifier values dropped and keys sorted;
empty, . and .. subpath segments dropped. On top of those, the
components a purl-spec type definition marks case-insensitive are
lowercased (PurlRules::CaseInsensitive), and pypi names follow
PEP 503 (PurlRules::Pypi). Rules the definitions give only in prose
(for example hackage’s “kebab-case”, pub’s underscores or cpan’s
uppercase author) are not applied, so two spellings that a type-aware tool
would treat as the same package may still compare unequal.
CanonicalPurl::rules says which rules applied.
Purl::check_type checks the requirements the definitions give as data:
a required or prohibited namespace, required qualifiers, and the
permitted characters of a name or version. Purl::parse does not apply
them, so a PURL its type does not allow still parses.
See docs/design/purl.md and the test-suite data under spec/purl/.
Structs§
- Canonical
Purl - A PURL in canonical form under
Self::rules. Comparable and hashable. - Purl
- A parsed Package URL. Holds the original text and never rewrites it.
Enums§
- Purl
Error - Why a string is not a Package URL.
- Purl
Rules - Which canonicalization rules produced a
CanonicalPurl. - Purl
Type Error - Why a PURL breaks a rule of its purl-spec type definition
(
Purl::check_type).
Constants§
- MAX_
PURL_ BYTES - Inputs longer than this, or whose canonical form would be, are rejected
with
PurlError::TooLong.
Functions§
- same_
package_ url - Whether two PURLs have the same canonical form (
Purl::canonical).