From 8220083568a5dca18f428e98fe1a92a15680f3af Mon Sep 17 00:00:00 2001 From: T727 <74924917+T-727@users.noreply.github.com> Date: Wed, 21 Jun 2023 13:08:33 +0300 Subject: [PATCH] feat(autoupdate): add hash 'match' mode --- lib/autoupdate.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/autoupdate.ps1 b/lib/autoupdate.ps1 index 803e994b6c..f4ae65c8a1 100644 --- a/lib/autoupdate.ps1 +++ b/lib/autoupdate.ps1 @@ -228,6 +228,12 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u $hashmode = 'sourceforge' } + $string = '' + if ($config.GetType().Name -eq 'String') { + $string = $config + $hashmode = 'match' + } + switch ($hashmode) { 'extract' { $hash = find_hash_in_textfile $hashfile_url $substitutions $regex @@ -255,6 +261,10 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u $hashfile_url = (strip_filename (strip_fragment "https://sourceforge.net/projects/$($matches['project'])/files/$($matches['file'])")).TrimEnd('/') $hash = find_hash_in_textfile $hashfile_url $substitutions '"$basename":.*?"sha1":\s*"([a-fA-F0-9]{40})"' } + 'match' { + $hash = substitute $string $substitutions + $hash = format_hash $hash + } } if ($hash) {