<commit_before><?php
/**
 * This file is part of the Imbo package
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE file that was
 * distributed with this source code.
 */

namespace Imbo;

use Imbo\Http\Request\Request,
    Imbo\Exception\RuntimeException,
    Imbo\Router\Route;

/**
 * Router class containing supported routes
 *
 * @author <NAME> <<EMAIL>>
 * @package Router
 */
class Router {
    /**
     * HTTP methods supported one way or another in Imbo
     *
     * @var array
     */
    static private $supportedHttpMethods = array(
        'GET'     => true,
        'POST'    => true,
        'PUT'     => true,
        'HEAD'    => true,
        'DELETE'  => true,
        'OPTIONS' => true,
        'SEARCH'  => true,
    );

    /**
     * The different routes that imbo handles
     *
     * @var array
     */
    private $routes = array(
        'image'          => '#^/users/(?<user>[a-z0-9_-]{1,})/images/(?<imageIdentifier>[a-f0-9]{32})(\.(?<extension>gif|jpg|png))?$#',
        'globalshorturl' => '#^/s/(?<shortUrlId>[a-zA-Z0-9]{7})$#',
        'status'         => '#^/status(/|(\.(?<extension>json|xml)))?$#',
        'images'         => '#^/users/(?<user>[a-z0-9_-]{1,})/images(/|(\.(?<extension>json|xml)))?$#',
        'metadata'       => '#^/users/(?<user>[a-z0-9_-]{1,})/images/(?<imageIdentifier>[a-f0-9]{32})/meta(?:data)?(/|\.(?<extension>json|xml))?$#',
        'user'           => '#^/users/(?<user>[a-z0-9_-]{1,})(/|\.(?<extension>json|xml))?$#',
        'stats'          => '#^/stats(/|(\.(?<extension>json|xml)))?$#',
        'index'          => '#^/?$#',
        'shorturls'      => '#^/users/(?<user>[a-z0-9_-]{1,})/images/(?<imageIdentifier>[a-f0-9]{32})/shorturls(/|\.(?<extension>json|xml))?$#',
        'shorturl'       => '#^/users/(?<user>[a-z0-9_-]{1,})/images/(?<imageIdentifier>[a-f0-9]{32})/shorturls/(?<shortUrlId>[a-zA-Z0-9]{7})$#',
        'groups'         => '#^/groups(/|(\.(?<extension>json|xml)))?$#',
        'group'          => '#^/groups/(?<group>[a-z0-9_-]{1,})(/|\.(?<extension>json|xml))?$#',
        'keys'           => '#^/keys/(?<publickey>[a-z0-9_-]{1,})$#',
        'accessrules'    => '#^/keys/(?<publickey>[a-z0-9_-]{1,})/access(/|(\.(?<extension>json|xml)))?$#',
        'accessrule'     => '#^/keys/(?<publickey>[a-z0-9_-]{1,})/access/(?<accessRuleId>[a-f0-9]{1,})(\.(?<extension>json|xml))?$#',
    );

    /**
     * Class constructor
     *
     * @param array $extraRoutes Extra routes passed in from configuration
     */
    public function __construct(array $extraRoutes = array()) {
        $this->routes = array_merge($this->routes, $extraRoutes);<commit_msg>Fixed routes to support both new and old image identifiers<commit_after><?php
/**
 * This file is part of the Imbo package
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE file that was
 * distributed with this source code.
 */

namespace Imbo;

use Imbo\Http\Request\Request,
    Imbo\Exception\RuntimeException,
    Imbo\Router\Route;

/**
 * Router class containing supported routes
 *
 * @author <NAME> <<EMAIL>>
 * @package Router
 */
class Router {
    /**
     * HTTP methods supported one way or another in Imbo
     *
     * @var array
     */
    static private $supportedHttpMethods = array(
        'GET'     => true,
        'POST'    => true,
        'PUT'     => true,
        'HEAD'    => true,
        'DELETE'  => true,
        'OPTIONS' => true,
        'SEARCH'  => true,
    );

    /**
     * The different routes that imbo handles
     *
     * @var array
     */
    private $routes = array(
        'image'          => '#^/users/(?<user>[a-z0-9_-]{1,})/images/(?<imageIdentifier>[a-f0-9-]{32,36})(\.(?<extension>gif|jpg|png))?$#',
        'globalshorturl' => '#^/s/(?<shortUrlId>[a-zA-Z0-9]{7})$#',
        'status'         => '#^/status(/|(\.(?<extension>json|xml)))?$#',
        'images'         => '#^/users/(?<user>[a-z0-9_-]{1,})/images(/|(\.(?<extension>json|xml)))?$#',
        'metadata'       => '#^/users/(?<user>[a-z0-9_-]{1,})/images/(?<imageIdentifier>[a-f0-9-]{32,36})/meta(?:data)?(/|\.(?<extension>json|xml))?$#',
        'user'           => '#^/users/(?<user>[a-z0-9_-]{1,})(/|\.(?<extension>json|xml))?$#',
        'stats'          => '#^/stats(/|(\.(?<extension>json|xml)))?$#',
        'index'          => '#^/?$#',
        'shorturls'      => '#^/users/(?<user>[a-z0-9_-]{1,})/images/(?<imageIdentifier>[a-f0-9-]{32,36})/shorturls(/|\.(?<extension>json|xml))?$#',
        'shorturl'       => '#^/users/(?<user>[a-z0-9_-]{1,})/images/(?<imageIdentifier>[a-f0-9-]{32,36})/shorturls/(?<shortUrlId>[a-zA-Z0-9]{7})$#',
        'groups'         => '#^/groups(/|(\.(?<extension>json|xml)))?$#',
        'group'          => '#^/groups/(?<group>[a-z0-9_-]{1,})(/|\.(?<extension>json|xml))?$#',
        'keys'           => '#^/keys/(?<publickey>[a-z0-9_-]{1,})$#',
        'accessrules'    => '#^/keys/(?<publickey>[a-z0-9_-]{1,})/access(/|(\.(?<extension>json|xml)))?$#',
        'accessrule'     => '#^/keys/(?<publickey>[a-z0-9_-]{1,})/access/(?<accessRuleId>[a-f0-9]{1,})(\.(?<extension>json|xml))?$#',
    );

    /**
     * Class constructor
     *
     * @param array $extraRoutes Extra routes passed in from configuration
     */
    public function __construct(array $extraRoutes = array()) {
        $this->routes = array_merge($this->routes, $extraRoutes);
{'fraction_non_alphanumeric': 0.2653472603994869, 'fraction_numerical': 0.02162360271211288, 'mean_word_length': 2.5766710353866316, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 119, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 20}, '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': '2230043', 'n_tokens_mistral': 2083, 'n_tokens_neox': 1999, 'n_words': 282}