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)) {
|
if (-not ($local.IsPresent)) {
|
||||||
Write-Information "Determining the file name of $location";
|
Write-Information "Determining the file name of $location";
|
||||||
$tempDir = $context.GetTempDirectory();
|
$fileName = ([uri]$location).Segments[-1];
|
||||||
$request = [System.Net.WebRequest]::Create($location);
|
|
||||||
$request.AllowAutoRedirect = $false;
|
|
||||||
$response = $request.GetResponse();
|
|
||||||
$fileName = [System.IO.Path]::GetFileName($response.GetResponseHeader("Location"));
|
|
||||||
Write-Information "$fileName";
|
Write-Information "$fileName";
|
||||||
$filePath = Join-Path $tempDir $fileName;
|
$filePath = Join-Path $tempDir $fileName;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue