<commit_before><?php

// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace App\Http\Controllers;

use App\Libraries\LocaleMeta;
use App\Libraries\OsuWiki;
use App\Libraries\Search\WikiSuggestions;
use App\Libraries\Search\WikiSuggestionsRequestParams;
use App\Libraries\Wiki\WikiSitemap;
use App\Libraries\WikiRedirect;
use App\Models\Wiki;
use Request;

/**
 * @group Wiki
 */
class WikiController extends Controller
{
    /**
     * Get Wiki Page
     *
     * The wiki article or image data.
     *
     * ---
     *
     * ### Response Format
     *
     * Returns [WikiPage](#wikipage).
     *
     * @urlParam page The path name of the wiki page.
     */
    public function show($locale = null, $path = null)
    {
        // redirect to default page if missing all parameters
        if ($locale === null) {
            return ujs_redirect(wiki_url(null, $this->locale()));
        }

        // if images slip through the markdown processing, redirect them to the correct place
        if (OsuWiki::isImage($path)) {
            return ujs_redirect(route('wiki.image', concat_path([$locale === 'images' ? null : $locale, $path])));
        }

        // if invalid locale, assume locale to be part of path and
        // actual locale to be either user locale or passed as parameter
        if (!LocaleMeta::isValid($locale)) {<commit_msg>Also don't prepend valid locale for image redirect<commit_after><?php

// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace App\Http\Controllers;

use App\Libraries\LocaleMeta;
use App\Libraries\OsuWiki;
use App\Libraries\Search\WikiSuggestions;
use App\Libraries\Search\WikiSuggestionsRequestParams;
use App\Libraries\Wiki\WikiSitemap;
use App\Libraries\WikiRedirect;
use App\Models\Wiki;
use Request;

/**
 * @group Wiki
 */
class WikiController extends Controller
{
    /**
     * Get Wiki Page
     *
     * The wiki article or image data.
     *
     * ---
     *
     * ### Response Format
     *
     * Returns [WikiPage](#wikipage).
     *
     * @urlParam page The path name of the wiki page.
     */
    public function show($locale = null, $path = null)
    {
        // redirect to default page if missing all parameters
        if ($locale === null) {
            return ujs_redirect(wiki_url(null, $this->locale()));
        }

        $validLocale = LocaleMeta::isValid($locale);

        // if images slip through the markdown processing, redirect them to the correct place
        if (OsuWiki::isImage($path)) {
            $prependPath = ($locale === 'images' || $validLocale) ? null : $locale;

            return ujs_redirect(route('wiki.image', concat_path([$prependPath, $path])));
        }

        // if invalid locale, assume locale to be part of path and
        // actual locale to be either user locale or passed as parameter
        if (!$validLocale) {
{'fraction_non_alphanumeric': 0.11150729335494328, 'fraction_numerical': 0.0012965964343598054, 'mean_word_length': 2.6913875598086126, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5436216', 'n_tokens_mistral': 911, 'n_tokens_neox': 895, 'n_words': 292}