<commit_before><?php

/**
 * RewriteRule Generator
 *
 * @license MIT
 * @author <NAME> <<EMAIL>> https://donatstudios.com/RewriteRule_Generator
 *
 */

use donatj\RewriteGenerator\ApacheModRewriteGenerator;
use donatj\RewriteGenerator\Engine;
use donatj\RewriteGenerator\RewriteTypes;

if( file_exists(__DIR__ . '/vendor/autoload.php') ) {
	require __DIR__ . '/vendor/autoload.php';
}

// Avoiding the composer autoloader momentarily for backwards compatibility
spl_autoload_register(function ( string $className ) {
	$parts = explode('\\', $className);
	array_shift($parts);
	array_shift($parts);
	$path = implode($parts, DIRECTORY_SEPARATOR);

	require "src/{$path}.php";
});

$paramRewrites = $_POST['tabbed_rewrites'] ?? <<<EOD
http://www.test.com/test.html	http://www.test.com/spiders.html
http://www.test.com/faq.html?faq=13&layout=bob	http://www.test2.com/faqs.html
http://www.test3.com/faq.html?faq=13&layout=bob	bbq.html
text/faq.html?faq=20	helpdesk/kb.php
EOD;
$paramComments = (bool)($_POST ? ($_POST['desc_comments'] ?? false) : true);
$paramType     = $_POST['type'] ?? RewriteTypes::PERMANENT_REDIRECT;

$generator = new ApacheModRewriteGenerator;

$engine = new Engine($generator);
$output = $engine->generate($paramRewrites, $paramType, $paramComments);
<commit_msg>Fixes UI bug where Dropdown didn’t re-select after post<commit_after><?php

/**
 * RewriteRule Generator
 *
 * @license MIT
 * @author <NAME> <<EMAIL>> https://donatstudios.com/RewriteRule_Generator
 *
 */

use donatj\RewriteGenerator\ApacheModRewriteGenerator;
use donatj\RewriteGenerator\Engine;
use donatj\RewriteGenerator\RewriteTypes;

if( file_exists(__DIR__ . '/vendor/autoload.php') ) {
	require __DIR__ . '/vendor/autoload.php';
}

// Avoiding the composer autoloader momentarily for backwards compatibility
spl_autoload_register(function ( string $className ) {
	$parts = explode('\\', $className);
	array_shift($parts);
	array_shift($parts);
	$path = implode($parts, DIRECTORY_SEPARATOR);

	require "src/{$path}.php";
});

$paramRewrites = $_POST['tabbed_rewrites'] ?? <<<EOD
http://www.test.com/test.html	http://www.test.com/spiders.html
http://www.test.com/faq.html?faq=13&layout=bob	http://www.test2.com/faqs.html
http://www.test3.com/faq.html?faq=13&layout=bob	bbq.html
text/faq.html?faq=20	helpdesk/kb.php
EOD;
$paramComments = (bool)($_POST ? ($_POST['desc_comments'] ?? false) : true);
$paramType     = (int)($_POST['type'] ?? RewriteTypes::PERMANENT_REDIRECT);

$generator = new ApacheModRewriteGenerator;

$engine = new Engine($generator);
$output = $engine->generate($paramRewrites, $paramType, $paramComments);

{'fraction_non_alphanumeric': 0.1673672143675965, 'fraction_numerical': 0.00611387084447841, 'mean_word_length': 5.782383419689119, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 10, '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': '1236304', 'n_tokens_mistral': 974, 'n_tokens_neox': 917, 'n_words': 152}