feat(purl): add canonicalizePurl to eol-shared (PR 1/3 — purl-identity-canonicalization)#28
Merged
Conversation
…ization Add canonicalizePurl to @herodevs/eol-shared: parses with packageurl-js, applies go->golang / rubygems->gem type aliases and lowercases namespace/name for case-insensitive ecosystems (nuget, composer, cargo, npm), then re-serializes. Exposes an optional onUncanonicalized hook so callers can observe serialize-failure passthroughs without breaking the never-throw contract. Includes the authoritative unit test suite and widens the test glob to run nested specs.
c05b202 to
744ff92
Compare
jeremymwells
approved these changes
Jun 24, 2026
v3nant
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
canonicalizePurlto@herodevs/eol-shared— a single canonical-identity function so the same logical package yields one docId / routing key / DB key across eol-engine (write) and eol-api (read).packageurl-js, applying onlygo→golang/rubygems→gemtype aliases and lowercasing namespace/name for case-insensitive ecosystems (nuget,composer,cargo,npm).golang/maven/gemnames are case-preserved;pypi/pubare left to the library.onUncanonicalized(purl, error)hook so consumers can observe serialize-failure passthroughs (metric/log) without breaking the never-throw contract.Context — PR 1 of 3 (cross-repo)
This is the first of three ordered PRs for the
purl-identity-canonicalizationchange. eol-shared must merge and be taggedv0.1.21before the consumers can pin it:v0.1.21Changes
src/eol/utils.tscanonicalizePurl(purl, onUncanonicalized?)(library-based parse → alias → case-fold → serialize), with a guarded observability hooksrc/eol/utils.test.tssrc/index.tscanonicalizePurlpackage.jsonsrc/**/*.test.*so nested specs are runBehavior notes
packageurl-js@2golang-validator limitation on bare-major versions like@v1) → returned unchanged and the optionalonUncanonicalizedhook fires. A hook that itself throws is swallowed.packageurl-jsmajor makes write and read produce identical output regardless of each consumer's own version.Test plan
npm ci(installs locked deps) — passesnpm run type-check— cleannpm run build— exit 0npm run lint— cleannpm run format:check— cleannpm run test— 174/174 pass (Node 22 & 24)packageurl-js@2.0.1