<commit_before><?php

namespace Perfumer\Proxy;

use Perfumer\Container\Core as Container;
use Perfumer\Proxy\Exception\ForwardException;
use Perfumer\Proxy\Exception\ProxyException;

class Core
{
    protected $container;
    protected $request_pool = [];

    protected $request_url;
    protected $request_action;
    protected $request_args = [];

    protected $http_prefixes = [];
    protected $http_id;
    protected $http_query = [];
    protected $http_args = [];

    public function __construct(Container $container)
    {
        $this->container = $container;
        $this->request_action = strtolower($_SERVER['REQUEST_METHOD']);

        if ($_SERVER['PATH_INFO'] == '/')
        {
            $this->request_url = $this->container->p('proxy.default_url');
        }
        else
        {
            $url = $_SERVER['PATH_INFO'];
            $hyphen_pos = strpos($url, '-');

            if ($hyphen_pos !== false)
            {
                $this->http_id = substr($url, $hyphen_pos + 1);
                $url = substr($url, 0, $hyphen_pos);
            }

            if ($prefixes = $this->container->p('proxy.prefixes'))
            {
                $url = explode('/', $url);
                array_shift($url);

                $prefix_values = array_slice($url, 0, count($prefixes));

                foreach ($prefixes as $key => $prefix)
                {
                    $this->http_prefixes[$prefix] = isset($prefix_values[$key]) ? $prefix_values[$key] : null;
                }

                if (count($prefixes) >= count($url))
                {
                    $url = $this->container->p('proxy.default_url');
                }
                else
                {
                    $url = array_slice($url, count($prefixes));
                    $url = implode('/', $url);
                }
            }

            $this->request_url = $url;
        }

        switch ($this->request_action)
        {
            case 'get':
                $this->http_query = $_GET;
                break;
            case 'post':
                $this->http_query = $_GET;
                $this->http_args = $_POST;
                break;<commit_msg>Proxy url analysing slash fix<commit_after><?php

namespace Perfumer\Proxy;

use Perfumer\Container\Core as Container;
use Perfumer\Proxy\Exception\ForwardException;
use Perfumer\Proxy\Exception\ProxyException;

class Core
{
    protected $container;
    protected $request_pool = [];

    protected $request_url;
    protected $request_action;
    protected $request_args = [];

    protected $http_prefixes = [];
    protected $http_id;
    protected $http_query = [];
    protected $http_args = [];

    public function __construct(Container $container)
    {
        $this->container = $container;
        $this->request_action = strtolower($_SERVER['REQUEST_METHOD']);

        if ($_SERVER['PATH_INFO'] == '/')
        {
            $this->request_url = $this->container->p('proxy.default_url');
        }
        else
        {
            $url = trim($_SERVER['PATH_INFO'], '/');
            $hyphen_pos = strpos($url, '-');

            if ($hyphen_pos !== false)
            {
                $this->http_id = substr($url, $hyphen_pos + 1);
                $url = substr($url, 0, $hyphen_pos);
            }

            if ($prefixes = $this->container->p('proxy.prefixes'))
            {
                $url = explode('/', $url);

                $prefix_values = array_slice($url, 0, count($prefixes));

                foreach ($prefixes as $key => $prefix)
                {
                    $this->http_prefixes[$prefix] = isset($prefix_values[$key]) ? $prefix_values[$key] : null;
                }

                if (count($prefixes) >= count($url))
                {
                    $url = $this->container->p('proxy.default_url');
                }
                else
                {
                    $url = array_slice($url, count($prefixes));
                    $url = implode('/', $url);
                }
            }

            $this->request_url = $url;
        }

        switch ($this->request_action)
        {
            case 'get':
                $this->http_query = $_GET;
                break;
            case 'post':
                $this->http_query = $_GET;
                $this->http_args = $_POST;
                break;
{'fraction_non_alphanumeric': 0.1403107861060329, 'fraction_numerical': 0.0013711151736745886, 'mean_word_length': 1.5656506447831184, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '7346937', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1175, 'n_words': 216}