Skip to content

Commit

Permalink
Format the callback URI, resolving a relative URI if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
sander3 authored and m1guelpf committed Mar 20, 2019
1 parent 2ee75ab commit 64b9edc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
}],
"require": {
"php": "^5.6 || ^7.0",
"laravel/socialite": "~3.0|~4.0"
"laravel/socialite": "~3.0|~4.0",
"illuminate/support": "~5.4|~5.7.0|~5.8.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0",
Expand Down
18 changes: 17 additions & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace SocialiteProviders\Manager;

use Illuminate\Support\Str;
use Illuminate\Support\Facades\URL;

class Config implements Contracts\ConfigInterface
{
/**
Expand All @@ -22,10 +25,23 @@ public function __construct($key, $secret, $callbackUri, array $additionalProvid
$this->config = array_merge([
'client_id' => $key,
'client_secret' => $secret,
'redirect' => $callbackUri,
'redirect' => $this->formatRedirectUri($callbackUri),
], $additionalProviderConfig);
}

/**
* Format the callback URI, resolving a relative URI if needed.
*
* @param string $callbackUri
* @return string
*/
protected function formatRedirectUri(string $callbackUri)
{
return Str::startsWith($callbackUri, '/')
? URL::to($callbackUri)
: $callbackUri;
}

/**
* @return array
*/
Expand Down

0 comments on commit 64b9edc

Please sign in to comment.