Nix: Fix name characters in prefetch.

This commit is contained in:
Dmitry Voronin 2024-11-27 16:52:07 +03:00
parent 372ba8bfad
commit 033901dfd7
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -51,13 +51,15 @@
# Usage: prefetch <URL> # Usage: prefetch <URL>
function prefetch() { function prefetch() {
local url="''${1}" local url="''${1}"
local name="''${1##*/}"
name=$(parse_alnum "''${name%%\?*}")
if [[ "''${url}" = "" ]]; then if [[ "''${url}" = "" ]]; then
help prefetch help prefetch
return 2 return 2
fi fi
local result=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url "''${url}")) local result=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url --name "''${name}" "''${url}"))
printf "%s" ''${result} | copy printf "%s" ''${result} | copy
printf "%s\n" ''${result} printf "%s\n" ''${result}
} }