Skip to content

Commit

Permalink
Merge pull request #19 from xp-forge/feature/alternate-domain
Browse files Browse the repository at this point in the history
Support alternate domains when passed a prefix ending with "."
  • Loading branch information
thekid authored Aug 17, 2024
2 parents b3fd188 + 6514b31 commit db425aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/php/com/amazon/aws/ServiceEndpoint.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public function domain() {
? "{$this->service}.amazonaws.com"
: "{$this->service}.{$this->region}.amazonaws.com"
;
} else if ('.' === $this->domain[strlen($this->domain) - 1]) {
return null === $this->region
? "{$this->domain}amazonaws.com"
: "{$this->domain}{$this->region}.amazonaws.com"
;
} else if (false === strpos($this->domain, '.')) {
return null === $this->region
? "{$this->domain}.{$this->service}.amazonaws.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ public function region_domain() {
);
}

#[Test]
public function service_alternate_domain() {
Assert::equals(
'bedrock-runtime.amazonaws.com',
(new ServiceEndpoint('bedrock', $this->credentials))->using('bedrock-runtime.')->domain()
);
}

#[Test, Values(['id', 'id.execute-api.eu-central-1.amazonaws.com'])]
public function use_domain_or_prefix($domain) {
Assert::equals(
Expand Down

0 comments on commit db425aa

Please sign in to comment.