1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6namespace App\Http\Controllers;
7
8class RedirectController extends Controller
9{
10 public function __invoke()
11 {
12 // encode args like wiki_url helper.
13 $args = array_map(function ($arg) {
14 // FIXME: remove `rawurlencode` workaround when fixed upstream.
15 // Reference: https://github.com/laravel/framework/issues/26715
16 return str_replace('%2F', '/', rawurlencode($arg));
17 }, func_get_args());
18
19 $status = request()->isMethodCacheable() ? 302 : 307;
20
21 return ujs_redirect(route(explode('redirect:', rtrim(\Route::currentRouteName(), ':'), 2)[1], $args), $status);
22 }
23}