Merge pull request #10763 from w41ter/fix_8882
Fix guess region from s3 URL
This commit is contained in:
commit
2a616b3866
|
@ -186,13 +186,12 @@ std::string guessRegionFromDomain(std::string domain) {
|
|||
const char* service = knownServices[i];
|
||||
|
||||
std::size_t p = domain.find(service);
|
||||
|
||||
if (p == std::string::npos || (p >= 1 && domain[p - 1] != '.')) {
|
||||
// eg. 127.0.0.1, example.com, s3-service.example.com, mys3.example.com
|
||||
continue;
|
||||
}
|
||||
|
||||
StringRef h(domain.c_str() + p);
|
||||
StringRef h = StringRef(domain).substr(p);
|
||||
|
||||
if (!h.startsWith("oss-"_sr)) {
|
||||
h.eat(service); // ignore s3 service
|
||||
|
@ -1886,3 +1885,15 @@ TEST_CASE("/backup/s3/v4headers") {
|
|||
|
||||
return Void();
|
||||
}
|
||||
|
||||
TEST_CASE("/backup/s3/guess_region") {
|
||||
std::string url = "blobstore://s3.us-west-2.amazonaws.com/resource_name?bucket=bucket_name&sa=1";
|
||||
|
||||
std::string resource;
|
||||
std::string error;
|
||||
S3BlobStoreEndpoint::ParametersT parameters;
|
||||
Reference<S3BlobStoreEndpoint> s3 = S3BlobStoreEndpoint::fromString(url, {}, &resource, &error, ¶meters);
|
||||
ASSERT(s3->getRegion() == "us-west-2");
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue