Simplify file name detection in URLs
This commit is contained in:
parent
e49d6af4e1
commit
6419257cd8
1 changed files with 1 additions and 5 deletions
|
@ -6,11 +6,7 @@ function Install-SoftwarePackage([Context] $context, [string] $location, [string
|
|||
|
||||
if (-not ($local.IsPresent)) {
|
||||
Write-Information "Determining the file name of $location";
|
||||
$tempDir = $context.GetTempDirectory();
|
||||
$request = [System.Net.WebRequest]::Create($location);
|
||||
$request.AllowAutoRedirect = $false;
|
||||
$response = $request.GetResponse();
|
||||
$fileName = [System.IO.Path]::GetFileName($response.GetResponseHeader("Location"));
|
||||
$fileName = ([uri]$location).Segments[-1];
|
||||
Write-Information "$fileName";
|
||||
$filePath = Join-Path $tempDir $fileName;
|
||||
|
||||
|
|
Loading…
Reference in a new issue