Preview:
$current_path = $this->request->getCurrentRequest()->headers->get('referer');
$path = explode('8000', $current_path);  
//8000 is just a part of a string, from where we are breaking the string.
$route_name = Url::fromUserInput($path[1])->getRouteName();
return $this->redirect($route_name, ['user' => $user->id()]);
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter