diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-09 10:22:44 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-09 10:22:44 +0200 |
| commit | e48715a01c6e63e50fda231ecc0c3b2d1213e421 (patch) | |
| tree | 4238853cfed87cfe1de44aa46d6ee4b10bd88be6 /mkhint | |
| parent | 0d994f33425728d5fca1af54ddc69da545a596f9 (diff) | |
| download | mkhintfile-e48715a01c6e63e50fda231ecc0c3b2d1213e421.tar.gz mkhintfile-e48715a01c6e63e50fda231ecc0c3b2d1213e421.zip | |
feat: _registry_name_from_url helper for nvchecker autodetect
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'mkhint')
| -rwxr-xr-x | mkhint | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -817,6 +817,32 @@ _has_nvchecker_section() { "$NVCHECKER_CONFIG" } +# Extract a package name from a language-registry download URL. +# Args: <url> <prgnam-fallback>. Prints the parsed name, or the fallback +# (PRGNAM) when no host-specific pattern matches. +_registry_name_from_url() { + local url="$1" fallback="$2" + case "$url" in + *crates.io/api/v1/crates/*) + # .../crates/NAME/NAME-VER.crate or .../crates/NAME/VER/download + printf '%s' "${url#*crates.io/api/v1/crates/}" | cut -d/ -f1 + return 0 ;; + *rubygems.org/downloads/*) + # /downloads/NAME-VER.gem + local base="${url##*/downloads/}"; base="${base%.gem}" + printf '%s' "${base%-*}" + return 0 ;; + *registry.npmjs.org/*) + # /NAME/-/NAME-VER.tgz (NAME may be @scope/pkg) + printf '%s' "${url#*registry.npmjs.org/}" | sed 's|/-/.*||' + return 0 ;; + *hackage.haskell.org/package/*) + printf '%s' "${url#*hackage.haskell.org/package/}" | cut -d/ -f1 + return 0 ;; + esac + printf '%s' "$fallback" +} + # Append an nvchecker [pkg] section to NVCHECKER_CONFIG, auto-detecting the # source from the package's .info DOWNLOAD/HOMEPAGE. No-op if section exists. add_nvchecker_section() { |
