Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Fix endpoint parsing bug in S3 repository
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Apr 18, 2022
1 parent 4be2e66 commit 1844366
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/SquirrelCli/Sync/S3Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Amazon;
Expand Down Expand Up @@ -172,7 +173,12 @@ await RetryAsync(() => _client.DeleteObjectAsync(new DeleteObjectRequest { Bucke

Log.Info("Done");

var endpoint = new Uri(_options.endpoint ?? RegionEndpoint.GetBySystemName(_options.region).GetEndpointForService("s3").Hostname);
var endpointHost = _options.endpoint ?? RegionEndpoint.GetBySystemName(_options.region).GetEndpointForService("s3").Hostname;

if (Regex.IsMatch(endpointHost, @"^https?:\/\/", RegexOptions.IgnoreCase)) {
endpointHost = new Uri(endpointHost, UriKind.Absolute).Host;
}

var baseurl = $"https://{_options.bucket}.{endpoint.Host}/{_prefix}";
Log.Info($"Bucket URL: {baseurl}");
Log.Info($"Setup URL: {baseurl}{setupFile.Name}");
Expand Down

0 comments on commit 1844366

Please sign in to comment.