Skip to content

Commit

Permalink
autoupdate: add 'regex' alias for 'find'
Browse files Browse the repository at this point in the history
  • Loading branch information
r15ch13 committed Sep 18, 2018
1 parent 76fdb6b commit 3453487
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u
$jsonpath = $config.jsonpath
$hashmode = 'json'
}
$regex = ''
if ($config.find) {
$regex = $config.find
}
if ($config.regex) {
$regex = $config.regex
}

if (!$hashfile_url -and $url -match "(?:downloads\.)?sourceforge.net\/projects?\/(?<project>[^\/]+)\/(?:files\/)?(?<file>.*)") {
$hashmode = 'sourceforge'
Expand All @@ -178,7 +185,7 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u

switch ($hashmode) {
'extract' {
$hash = find_hash_in_textfile $hashfile_url $basename $config.find
$hash = find_hash_in_textfile $hashfile_url $basename $regex
}
'json' {
$hash = find_hash_in_json $hashfile_url $basename $jsonpath
Expand Down
5 changes: 5 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"additionalProperties": false,
"properties": {
"find": {
"format": "regex",
"type": "string",
"description": "Same as 'regex'"
},
"regex": {
"format": "regex",
"type": "string"
},
Expand Down

0 comments on commit 3453487

Please sign in to comment.