Skip to content

Commit

Permalink
checkver: add 'useragent' property
Browse files Browse the repository at this point in the history
  • Loading branch information
r15ch13 committed Sep 18, 2018
1 parent 7275403 commit 8feb386
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bin/checkver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ $original = use_any_https_protocol

# start all downloads
$queue | ForEach-Object {
$wc = New-Object Net.Webclient
$wc.Headers.Add('User-Agent', (Get-UserAgent))
register-objectevent $wc downloadstringcompleted -ea stop | out-null

$name, $json = $_

$substitutions = get_version_substitutions $json.version

$wc = New-Object Net.Webclient
if($json.checkver.useragent) {
$wc.Headers.Add('User-Agent', (substitute $json.checkver.useragent $substitutions))
} else {
$wc.Headers.Add('User-Agent', (Get-UserAgent))
}
Register-ObjectEvent $wc downloadstringcompleted -ErrorAction stop | Out-Null

$githubRegex = "\/releases\/tag\/(?:v)?([\d.]+)"

$url = $json.homepage
Expand Down Expand Up @@ -100,7 +106,6 @@ $queue | ForEach-Object {

$reverse = $json.checkver.reverse -and $json.checkver.reverse -eq "true"

$substitutions = get_version_substitutions $json.version
$url = substitute $url $substitutions

$state = new-object psobject @{
Expand Down
3 changes: 3 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@
"replace": {
"description": "Allows rearrange the regexp matches",
"type": "string"
},
"useragent": {
"type": "string"
}
},
"type": "object"
Expand Down

0 comments on commit 8feb386

Please sign in to comment.