Skip to content

Commit

Permalink
Also clean the clean from url
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryMoustache committed Dec 13, 2023
1 parent 290581a commit 844a286
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
13 changes: 6 additions & 7 deletions src/Http/Middleware/Redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ public function handle(Request $request, Closure $next)
];

$activeRedirect = $urlMaps->first(function ($redirect) use ($current) {
$hasWildcard = Str::contains(
$redirect->clean_from,
config('filament-redirects.route-wildcard', '*')
);
$from = $redirect->clean_from;

$hasWildcard = Str::contains($from, config('filament-redirects.route-wildcard', '*'));

return
($hasWildcard && Str::is($redirect->clean_from, $current['path'])) ||
($hasWildcard && Str::is($redirect->clean_from, $current['full'])) ||
(in_array($redirect->clean_from, $current));
($hasWildcard && Str::is($from, $current['path'])) ||
($hasWildcard && Str::is($from, $current['full'])) ||
(in_array($from, $current));
});

if (! $activeRedirect) {
Expand Down
16 changes: 11 additions & 5 deletions src/Models/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ protected static function boot()

public function getCleanFromAttribute()
{
return trim((
Str::startsWith($this->from, '/') || Str::startsWith($this->from, 'http')
? ''
: '/'
) . $this->from);
return Str::ascii(
urldecode(
trim(
(
Str::startsWith($this->from, '/') || Str::startsWith($this->from, 'http')
? ''
: '/'
) . $this->from
)
)
);
}

/**
Expand Down

0 comments on commit 844a286

Please sign in to comment.