Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(checkver): URL ping equality with dl function #188

Merged
merged 4 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u
Write-Host ' to verify URL accessibility' -ForegroundColor 'Yellow'
$request = [System.Net.WebRequest]::Create($url) # TODO: Consider spliting #/ from URL to prevent potential faulty response
$request.AllowAutoRedirect = $true
if ($PSVersionTable.PSVersion.Major -lt 6) {
$request.UserAgent = $SHOVEL_USERAGENT
$request.Referer = strip_filename $url
} else {
$request.Headers.Add('Referer', (strip_filename $url))
$request.Headers.Add('User-Agent', $SHOVEL_USERAGENT)
}
try {
$response = $request.GetResponse()
$response.Close()
Expand Down
4 changes: 2 additions & 2 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,9 @@ function Invoke-ExternalCommand {

function dl($url, $to) {
$wc = New-Object System.Net.Webclient
$wc.headers.add('Referer', (strip_filename $url))
$wc.Headers.Add('Referer', (strip_filename $url))
$wc.Headers.Add('User-Agent', $SHOVEL_USERAGENT)
$wc.downloadFile($url, $to)
$wc.DownloadFile($url, $to)
}

function env($name, $global, $val = '__get') {
Expand Down
2 changes: 1 addition & 1 deletion test/Shovel-Manifest.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Describe 'Manifests operations' -Tag 'Scoop' {

It 'Error handling' {
{ manifest_path 'invalid_wget' 'main' | Resolve-ManifestInformation } | Should -Throw 'Not a valid manifest'
( { manifest_path 'broken_wget' 'main' | Resolve-ManifestInformation } | Should -Throw -Passthru).Exception.Message | Should -BeLike 'File is not a valid manifest*'
( { manifest_path 'broken_wget' 'main' | Resolve-ManifestInformation } | Should -Throw -PassThru).Exception.Message | Should -BeLike 'File is not a valid manifest*'
}
}

Expand Down