File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ protected function createClient(array $config)
7979 'endpoint ' => $ config ['endpoint ' ] ?? null ,
8080 ];
8181
82- if ( preg_match ('#^https?://#i ' , $ dynamoConfig ['endpoint ' ]) === 0 ){
82+ if (! empty ( $ dynamoConfig [ ' endpoint ' ]) && preg_match ('#^https?://#i ' , $ dynamoConfig ['endpoint ' ]) === 0 ) {
8383 $ dynamoConfig ['endpoint ' ] = "https:// " . $ dynamoConfig ['endpoint ' ];
8484 }
8585
Original file line number Diff line number Diff line change @@ -96,4 +96,30 @@ public function it_can_forward_call_to_dynamodb_client()
9696 'TableName ' => 'User '
9797 ]);
9898 }
99+
100+ /** @test */
101+ public function it_prepends_default_protocol_if_not_given ()
102+ {
103+ $ connection = new Connection (['endpoint ' => 'examples.com ' ]);
104+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getScheme (), 'https ' );
105+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getHost (), 'examples.com ' );
106+ $ this ->assertEquals ($ this ->connection ->getClient ()->getEndpoint ()->getScheme (), 'https ' );
107+ $ this ->assertEquals ($ this ->connection ->getClient ()->getEndpoint ()->getHost (), 'dynamodb.us-east-1.amazonaws.com ' );
108+ }
109+
110+ /** @test */
111+ public function it_dont_prepends_default_protocol_if_http_given ()
112+ {
113+ $ connection = new Connection (['endpoint ' => 'http://examples.com ' ]);
114+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getScheme (), 'http ' );
115+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getHost (), 'examples.com ' );
116+ }
117+
118+ /** @test */
119+ public function it_dont_prepends_default_protocol_if_https_given ()
120+ {
121+ $ connection = new Connection (['endpoint ' => 'https://examples.com ' ]);
122+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getScheme (), 'https ' );
123+ $ this ->assertEquals ($ connection ->getClient ()->getEndpoint ()->getHost (), 'examples.com ' );
124+ }
99125}
You can’t perform that action at this time.
0 commit comments