Skip to content

Commit 6e73aa9

Browse files
authored
remove fallback parsing logic (#574)
1 parent d48e000 commit 6e73aa9

File tree

2 files changed

+0
-91
lines changed

2 files changed

+0
-91
lines changed

Diff for: src/dotnet-install.ps1

-31
Original file line numberDiff line numberDiff line change
@@ -992,32 +992,6 @@ function PrintDryRunOutput($Invocation, $DownloadLinks) {
992992
}
993993
}
994994

995-
# grab the 'stem' of the redirect and check it against all of our configured feeds,
996-
# if it matches, we can be sure that the redirect is valid and we should use it for
997-
# subsequent processing
998-
function Sanitize-RedirectUrl([string]$url) {
999-
$urlSegments = ([System.Uri]$url).Segments;
1000-
$urlStem = $urlSegments[2..($urlSegments.Length - 1)] -join "";
1001-
Write-Verbose "Checking configured feeds for the asset at $urlStem"
1002-
foreach ($prospectiveFeed in $feeds) {
1003-
$trialUrl = "$prospectiveFeed/$urlStem";
1004-
Write-Verbose "Checking $trialUrl"
1005-
try {
1006-
$trialResponse = Invoke-WebRequest -Uri $trialUrl -Method HEAD
1007-
if ($trialResponse.StatusCode -eq 200) {
1008-
Write-Verbose "Found a match at $trialUrl"
1009-
return $trialUrl;
1010-
}
1011-
else {
1012-
Write-Verbose "No match at $trialUrl"
1013-
}
1014-
}
1015-
catch {
1016-
Write-Verbose "Failed to check $trialUrl"
1017-
}
1018-
}
1019-
}
1020-
1021995
function Get-AkaMSDownloadLink([string]$Channel, [string]$Quality, [bool]$Internal, [string]$Product, [string]$Architecture) {
1022996
Say-Invocation $MyInvocation
1023997

@@ -1076,11 +1050,6 @@ function Get-AkaMSDownloadLink([string]$Channel, [string]$Quality, [bool]$Intern
10761050
}
10771051
elseif ((($Response.StatusCode -lt 300) -or ($Response.StatusCode -ge 400)) -and (-not [string]::IsNullOrEmpty($akaMsDownloadLink))) {
10781052
# Redirections have ended.
1079-
$actualRedirectUrl = Sanitize-RedirectUrl $akaMsDownloadLink
1080-
if ($null -ne $actualRedirectUrl) {
1081-
$akaMsDownloadLink = $actualRedirectUrl
1082-
}
1083-
10841053
return $akaMsDownloadLink
10851054
}
10861055

Diff for: src/dotnet-install.sh

-60
Original file line numberDiff line numberDiff line change
@@ -1272,61 +1272,6 @@ downloadwget() {
12721272
return 0
12731273
}
12741274

1275-
extract_stem() {
1276-
local url="$1"
1277-
# extract the protocol
1278-
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
1279-
# remove the protocol
1280-
url="${1/$proto/}"
1281-
# extract the path (if any) - since we know all of our feeds have a first path segment, we can skip the first one. otherwise we'd use -f2- to get the full path
1282-
full_path="$(echo $url | grep / | cut -d/ -f2-)"
1283-
path="$(echo $full_path | cut -d/ -f2-)"
1284-
echo $path
1285-
}
1286-
1287-
check_url_exists() {
1288-
eval $invocation
1289-
local url="$1"
1290-
1291-
local code=""
1292-
if machine_has "curl"
1293-
then
1294-
code=$(curl --head -o /dev/null -w "%{http_code}" -s --fail "$url");
1295-
elif machine_has "wget"
1296-
then
1297-
# get the http response, grab the status code
1298-
server_response=$(wget -qO- --method=HEAD --server-response "$url" 2>&1)
1299-
code=$(echo "$server_response" | grep "HTTP/" | awk '{print $2}')
1300-
fi
1301-
if [ $code = "200" ]; then
1302-
return 0
1303-
else
1304-
return 1
1305-
fi
1306-
}
1307-
1308-
sanitize_redirect_url() {
1309-
eval $invocation
1310-
1311-
local url_stem
1312-
url_stem=$(extract_stem "$1")
1313-
say_verbose "Checking configured feeds for the asset at ${yellow:-}$url_stem${normal:-}"
1314-
1315-
for feed in "${feeds[@]}"
1316-
do
1317-
local trial_url="$feed/$url_stem"
1318-
say_verbose "Checking ${yellow:-}$trial_url${normal:-}"
1319-
if check_url_exists "$trial_url"; then
1320-
say_verbose "Found a match at ${yellow:-}$trial_url${normal:-}"
1321-
echo "$trial_url"
1322-
return 0
1323-
else
1324-
say_verbose "No match at ${yellow:-}$trial_url${normal:-}"
1325-
fi
1326-
done
1327-
return 1
1328-
}
1329-
13301275
get_download_link_from_aka_ms() {
13311276
eval $invocation
13321277

@@ -1379,11 +1324,6 @@ get_download_link_from_aka_ms() {
13791324
return 1
13801325
fi
13811326

1382-
sanitized_redirect_url=$(sanitize_redirect_url "$aka_ms_download_link")
1383-
if [[ -n "$sanitized_redirect_url" ]]; then
1384-
aka_ms_download_link="$sanitized_redirect_url"
1385-
fi
1386-
13871327
say_verbose "The redirect location retrieved: '$aka_ms_download_link'."
13881328
return 0
13891329
else

0 commit comments

Comments
 (0)