Skip to content

Commit

Permalink
feat(autoupdate): Better regex debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed Aug 18, 2021
1 parent 66c3828 commit 5bd0d1f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ function find_hash_in_textfile([String] $url, [Hashtable] $substitutions, [Strin
if ($hash.Length -eq 0) {
$filenameRegex = "([a-fA-F\d]{32,128})[\x20\t]+.*`$basename(?:[\x20\t]+\d+)?"
$filenameRegex = Invoke-VariableSubstitution -Entity $filenameRegex -Substitutes $substitutions -EscapeRegularExpression:$true
debug $filenameRegex
if ($hashfile -match $filenameRegex) {
$hash = $Matches[1]
}
$metalinkRegex = '<hash[^>]+>([a-fA-F\d]{64})'
if ($hashfile -match $metalinkRegex) {
$hash = $Matches[1]

if ($hash.Length -eq 0) {
$metalinkRegex = '<hash[^>]+>([a-fA-F\d]{64})'
debug $metalinkRegex
if ($hashfile -match $metalinkRegex) {
$hash = $Matches[1]
}
}
}

Expand Down

0 comments on commit 5bd0d1f

Please sign in to comment.