<commit_before><?php

namespace Firelit;

class Router extends Singleton {
	
	protected $method, $uri, $match = false, $default, $error = array(), $exceptionHandler = false;
	protected $testMode = false;

	public $request, $response, $parameters = array();
	
	public static $proto = 'http', $domain = 'localhost', $rootPath = '/', $catchExceptions = false;
	
	public function __construct(Request $request = null) {

		// Check registry for router, if not passed
		if (is_null($request)) $request = Registry::get('Router');
	
		$this->request = $request;
		
		$this->method = $request->method;
		
		$rootPath = self::$rootPath;
		if (preg_match('!/$!', $rootPath)) $rootPath = substr($rootPath, 0, -1);
		
		$this->uri = preg_replace('!^'. preg_quote($rootPath) .'!', '', $request->path);
		if (strpos($this->uri, '?')) $this->uri = substr($this->uri, 0, strpos($this->uri, '?'));
		
	}
	
	public function __destruct() {

		if ($this->match || !is_callable($this->default)) return; // Response already sent or no default set
		if (in_array(http_response_code(), array(301, 302, 303)) return; // No default route if redirect

		try {
<commit_msg>Fixed typo<commit_after><?php

namespace Firelit;

class Router extends Singleton {
	
	protected $method, $uri, $match = false, $default, $error = array(), $exceptionHandler = false;
	protected $testMode = false;

	public $request, $response, $parameters = array();
	
	public static $proto = 'http', $domain = 'localhost', $rootPath = '/', $catchExceptions = false;
	
	public function __construct(Request $request = null) {

		// Check registry for router, if not passed
		if (is_null($request)) $request = Registry::get('Router');
	
		$this->request = $request;
		
		$this->method = $request->method;
		
		$rootPath = self::$rootPath;
		if (preg_match('!/$!', $rootPath)) $rootPath = substr($rootPath, 0, -1);
		
		$this->uri = preg_replace('!^'. preg_quote($rootPath) .'!', '', $request->path);
		if (strpos($this->uri, '?')) $this->uri = substr($this->uri, 0, strpos($this->uri, '?'));
		
	}
	
	public function __destruct() {

		if ($this->match || !is_callable($this->default)) return; // Response already sent or no default set
		if (in_array(http_response_code(), array(301, 302, 303))) return; // No default route if redirect

		try {

{'fraction_non_alphanumeric': 0.18416447944007, 'fraction_numerical': 0.010498687664041995, 'mean_word_length': 4.445238095238095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '7520329', 'n_tokens_mistral': 809, 'n_tokens_neox': 718, 'n_words': 199}