<commit_before><?php

namespace KiaKing\LaravelLocale;

use Illuminate\Http\Request;
use Illuminate\Contracts\Config\Repository as Config;
use Illuminate\Contracts\Routing\UrlGenerator;

class LocaleUrlGenerator
{
    /**
     * Instance of config.
     *
     * @var \Illuminate\Contracts\Config\Repository
     */
    protected $config;

    /**
     * Instance of request.
     *
     * @var \Illuminate\Http\Request
     */
    protected $request;

    /**
     * Instance of url generator.
     *
     * @var \Illuminate\Contracts\Routing\UrlGenerator
     */
    protected $url;

    /**
     * Create LocaleUrlGenerator instance.
     *
     * @param \Illuminate\Contracts\Config\Repository $config
     * @param \Illuminate\Http\Request $request
     * @param \Illuminate\Contracts\Routing\UrlGenerator $url
     */
    function __construct(Config $config, Request $request, UrlGenerator $url)
    {
        $this->config = $config;
        $this->request = $request;
        $this->url = $url;
    }

    /**
     * Generate a absolute URL to the given path.
     *
     * @param  string $path
     * @param  mixed  $extra
     * @param  bool   $secure
     * @return string
     */
    public function url($path, $extra = [], $secure = null)
    {
        if ($this->isCurrentLocaleDefault()) {
            return $this->url->to($path, $extra, $secure);
        }

        $path = $this->config->get('app.locale') . '/' . $path;

        return $this->url->to($path, $extra, $secure);
    }

    /**
     * Get the URL to a named route.
     *
     * @param  string $name
     * @param  mixed  $parameters
     * @param  bool   $absolute
     * @return string
     */
    public function route($name, $parameters = [], $absolute = true)
    {
        if ($this->isCurrentLocaleDefault()) {
            return $this->url->route($name, $parameters, $absolute);
        }

        $name = $this->config->get('app.locale') . '.' . $name;
<commit_msg>Do not change url if it starts with "http"<commit_after><?php

namespace KiaKing\LaravelLocale;

use Illuminate\Http\Request;
use Illuminate\Contracts\Config\Repository as Config;
use Illuminate\Contracts\Routing\UrlGenerator;

class LocaleUrlGenerator
{
    /**
     * Instance of config.
     *
     * @var \Illuminate\Contracts\Config\Repository
     */
    protected $config;

    /**
     * Instance of request.
     *
     * @var \Illuminate\Http\Request
     */
    protected $request;

    /**
     * Instance of url generator.
     *
     * @var \Illuminate\Contracts\Routing\UrlGenerator
     */
    protected $url;

    /**
     * Create LocaleUrlGenerator instance.
     *
     * @param \Illuminate\Contracts\Config\Repository $config
     * @param \Illuminate\Http\Request $request
     * @param \Illuminate\Contracts\Routing\UrlGenerator $url
     */
    function __construct(Config $config, Request $request, UrlGenerator $url)
    {
        $this->config = $config;
        $this->request = $request;
        $this->url = $url;
    }

    /**
     * Generate a absolute URL to the given path.
     *
     * @param  string $path
     * @param  mixed  $extra
     * @param  bool   $secure
     * @return string
     */
    public function url($path, $extra = [], $secure = null)
    {
        // Do not modify path if it starts with `http`.
        if (preg_match('/^http/', $path)) {
            return $this->url->to($path, $extra, $secure);
        }

        if ($this->isCurrentLocaleDefault()) {
            return $this->url->to($path, $extra, $secure);
        }

        $path = $this->config->get('app.locale') . '/' . $path;

        return $this->url->to($path, $extra, $secure);
    }

    /**
     * Get the URL to a named route.
     *
     * @param  string $name
     * @param  mixed  $parameters
     * @param  bool   $absolute
     * @return string
     */
    public function route($name, $parameters = [], $absolute = true)
    {
        if ($this->isCurrentLocaleDefault()) {
            return $this->url->route($name, $parameters, $absolute);
        }

        $name = $this->config->get('app.locale') . '.' . $name;

{'fraction_non_alphanumeric': 0.14376064217951837, 'fraction_numerical': 0.0, 'mean_word_length': 2.119878603945372, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '2353345', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1264, 'n_words': 286}