Skip to content

Commit 8001216

Browse files
authored
cleanup(rest): stricter schema checking in EndpointOption (#13397)
1 parent 0b714fc commit 8001216

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

google/cloud/internal/populate_rest_options.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Options PopulateRestOptions(Options opts) {
4040
// Use an unqualified domain name, because we do not seem to reuse
4141
// connections with a fully qualified domain name over REST.
4242
if (absl::EndsWith(endpoint, ".googleapis.com.")) endpoint.pop_back();
43-
if (!absl::StartsWithIgnoreCase(endpoint, "http")) {
43+
if (!absl::StartsWithIgnoreCase(endpoint, "http://") &&
44+
!absl::StartsWithIgnoreCase(endpoint, "https://")) {
4445
endpoint = absl::StrCat("https://", endpoint);
4546
}
4647
}

google/cloud/internal/populate_rest_options_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ TEST(PopulateRestOptions, EndpointOption) {
3939
};
4040
std::vector<TestCase> cases = {
4141
{"example.com", "https://example.com"},
42+
{"http-but-not-the-schema.com", "https://http-but-not-the-schema.com"},
4243
{"foo.googleapis.com.", "https://foo.googleapis.com"},
4344
{"https://foo.googleapis.com.", "https://foo.googleapis.com"},
4445
{"http://example.com", "http://example.com"},

0 commit comments

Comments
 (0)