Skip to content

Commit

Permalink
fix: left trim url if there is a trailing slash (#5149)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed May 3, 2021
1 parent 873a8d7 commit 56572bb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/Api/Auth/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Api\Auth;

use App\Models\User\User;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use function Safe\json_decode;
use Illuminate\Http\JsonResponse;
Expand Down Expand Up @@ -190,7 +191,7 @@ private function handleVerify(Request $request): ?JsonResponse
*/
private function proxy(array $data = []): array
{
$url = App::runningUnitTests() ? config('app.url').'/oauth/token' : route('passport.token');
$url = App::runningUnitTests() ? Str::of(config('app.url'))->ltrim('/').'/oauth/token' : route('passport.token');
/** @var \Illuminate\Http\Response */
$response = app(Kernel::class)->handle(Request::create($url, 'POST', [
'grant_type' => $data['grantType'],
Expand Down
3 changes: 2 additions & 1 deletion app/Notifications/EmailMessaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Notifications;

use App\Models\User\User;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\App;
use Illuminate\Notifications\Messages\MailMessage;

Expand Down Expand Up @@ -40,7 +41,7 @@ public static function resetPasswordMail(User $user, $token): MailMessage
->subject(trans('mail.password_reset_title'))
->line(trans('mail.password_reset_title'))
->line(trans('mail.password_reset_intro'))
->action(trans('mail.password_reset_button'), url(config('app.url').route('password.reset', ['token' => $token, 'email' => $user->getEmailForPasswordReset()], false)))
->action(trans('mail.password_reset_button'), url(Str::of(config('app.url'))->ltrim('/').route('password.reset', ['token' => $token, 'email' => $user->getEmailForPasswordReset()], false)))
->line(trans('mail.password_reset_expiration', ['count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')]))
->line(trans('mail.password_reset_bottom'));
}
Expand Down
3 changes: 2 additions & 1 deletion app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Providers;

use Illuminate\Support\Str;
use Illuminate\Routing\Router;
use App\Models\Contact\Contact;
use App\Services\Instance\IdHasher;
Expand Down Expand Up @@ -35,7 +36,7 @@ public function boot()
parent::boot();

if (Config::get('app.force_url')) {
URL::forceRootUrl(config('app.url'));
URL::forceRootUrl(Str::of(config('app.url'))->ltrim('/'));
}

if (App::environment('production')) {
Expand Down
2 changes: 1 addition & 1 deletion resources/views/vendor/mail/html/message.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@component('mail::layout')
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
@component('mail::header', ['url' => Str::of(config('app.url'))->ltrim('/')])
{{ config('app.name') }}
@endcomponent
@endslot
Expand Down
2 changes: 1 addition & 1 deletion resources/views/vendor/mail/text/message.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@component('mail::layout')
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
@component('mail::header', ['url' => Str::of(config('app.url'))->ltrim('/')])
{{ config('app.name') }}
@endcomponent
@endslot
Expand Down

0 comments on commit 56572bb

Please sign in to comment.