Commit de75f319 authored by Kevin Ditscheid's avatar Kevin Ditscheid

Merge branch 'feature_CaseSensitiveSourceUrl' into 'master'

Feature case sensitive source url

See merge request !7
parents 3b6fa789 549bbec3
......@@ -120,8 +120,8 @@ class RoutingService {
$where = 'deleted = 0 AND pid = ' . $rootUid;
$resultArray = $databaseConnection->exec_SELECTgetRows(
'uid, pid, use_regular_expression, source_url, destination_url, ' .
'redirect_url_parameters, redirect_code, description',
'uid, pid, use_regular_expression, source_url, source_url_case_sensitive, ' .
'destination_url, redirect_url_parameters, redirect_code, description',
$tableName, $where, '',
'sorting'
);
......@@ -152,7 +152,16 @@ class RoutingService {
header('Location: ' . $redirectUri, TRUE, $redirect['redirect_code']);
exit();
}
} elseif (\rawurldecode($requestUri) === $trimmedSourceUrl) {
} elseif (
(
(bool)$redirect['source_url_case_sensitive'] &&
\rawurldecode($requestUri) === $trimmedSourceUrl
) ||
(
!(bool)$redirect['source_url_case_sensitive'] &&
\mb_strtolower(\rawurldecode($requestUri)) === \mb_strtolower($trimmedSourceUrl)
)
) {
$destinationUrl = $redirect['destination_url'];
if (strpos($destinationUrl, self::URL_WIZARD_ID) === 0) {
$destinationUrl = (int) substr($destinationUrl, 14);
......@@ -443,8 +452,26 @@ class RoutingService {
if ($route['use_regular_expression']) {
$directive = 'RedirectMatch';
}
$htaccessEntries .= $directive . ' ' . $route['redirect_code'] . ' ' . $route['source_url'] . ' '
. $route['destination_url'] . LF;
if (!$route['source_url_case_sensitive']) {
$directive = 'RedirectMatch';
$route['source_url'] = '(?i)' . \addslashes($route['source_url']);
}
if (
\is_numeric($route['destination_url']) ||
\substr($route['destination_url'], 0, 5) === 't3://'
) {
/**
* @var $routingService RoutingService
*/
$routingService = GeneralUtility::makeInstance(self::class);
$tsfe = $routingService->getTypoScriptFrontendController();
$route['destination_url'] = $tsfe->cObj->getTypoLink_URL($route['destination_url']);
}
if ($route['destination_url'] !== '') {
// only add the htaccess rule if there is a destination, because otherwise it will be 404 anyway
$htaccessEntries .= $directive . ' ' . $route['redirect_code'] . ' '
. $route['source_url'] . ' ' . $route['destination_url'] . LF;
}
}
}
......
......@@ -2,9 +2,9 @@
if (\SGalinski\SgRoutes\Service\LicensingService::checkKey()) {
$showFields = 'use_regular_expression, regular_expression_info, source_url, destination_url, redirect_url_parameters, redirect_code, description, categories';
$showFields = 'use_regular_expression, regular_expression_info, --palette--;LLL:EXT:sg_routes/Resources/Private/Language/locallang_db.xlf:tx_sgroutes_domain_model_route.palettes.source_url;source_url, destination_url, redirect_url_parameters, redirect_code, description, categories';
} else {
$showFields = 'source_url, destination_url, redirect_url_parameters, redirect_code, description, categories';
$showFields = '--palette--;LLL:EXT:sg_routes/Resources/Private/Language/locallang_db.xlf:tx_sgroutes_domain_model_route.palettes.source_url;source_url, destination_url, redirect_url_parameters, redirect_code, description, categories';
}
return [
......@@ -32,13 +32,18 @@ return [
'iconfile' => 'EXT:sg_routes/Resources/Public/Icons/tx_sgroutes_domain_model_route.svg'
],
'interface' => [
'showRecordFieldList' => 'hidden, use_regular_expression, source_url, destination_url, redirect_url_parameters, redirect_code, description',
'showRecordFieldList' => 'hidden, use_regular_expression, source_url, source_url_case_sensitive, destination_url, redirect_url_parameters, redirect_code, description',
],
'types' => [
'1' => [
'showitem' => $showFields,
],
],
'palettes' => [
'source_url' => [
'showitem' => 'source_url,source_url_case_sensitive'
]
],
'columns' => [
't3ver_label' => [
'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.versionLabel',
......@@ -84,6 +89,15 @@ return [
'eval' => 'trim'
],
],
'source_url_case_sensitive' => [
'exclude' => 0,
'label' => 'LLL:EXT:sg_routes/Resources/Private/Language/locallang_db.xlf:tx_sgroutes_domain_model_route.source_url_case_sensitive',
'config' => [
'type' => 'check',
'default' => '1'
],
'displayCond' => 'FIELD:use_regular_expression:!=:1'
],
'destination_url' => [
'exclude' => 0,
'label' => 'LLL:EXT:sg_routes/Resources/Private/Language/locallang_db.xlf:tx_sgroutes_domain_model_route.destination_url',
......
......@@ -117,10 +117,18 @@
<source>Regular Expression Tester</source>
<target>Reguläre Ausdrücke Tester</target>
</trans-unit>
<trans-unit id="tx_sgroutes_domain_model_route.palettes.source_url">
<source>Source URL</source>
<target>Quell-URL</target>
</trans-unit>
<trans-unit id="tx_sgroutes_domain_model_route.source_url" approved="yes">
<source>Source URL (Examples: "/contact/" , "^/contact/(.*)$")</source>
<target>Quell-URL (Beispiele: "/kontakt/" , "^/kontakt/(.*)$")</target>
</trans-unit>
<trans-unit id="tx_sgroutes_domain_model_route.source_url_case_sensitive">
<source>Case sensitive check</source>
<target>Groß- und Kleinschreibung beachten</target>
</trans-unit>
<trans-unit id="tx_sgroutes_domain_model_route.temporary" approved="yes">
<source>302 (Temporary Redirect)</source>
<target>302 (Temporäre Weiterleitung)</target>
......
......@@ -90,9 +90,15 @@
<trans-unit id="tx_sgroutes_domain_model_route.regular_expression_info_tester">
<source>Regular Expression Tester</source>
</trans-unit>
<trans-unit id="tx_sgroutes_domain_model_route.palettes.source_url">
<source>Source URL</source>
</trans-unit>
<trans-unit id="tx_sgroutes_domain_model_route.source_url">
<source>Source URL (Examples: "/contact/" , "^/contact/(.*)$")</source>
</trans-unit>
<trans-unit id="tx_sgroutes_domain_model_route.source_url_case_sensitive">
<source>Case sensitive check</source>
</trans-unit>
<trans-unit id="tx_sgroutes_domain_model_route.temporary">
<source>302 (Temporary Redirect)</source>
</trans-unit>
......
......@@ -7,6 +7,7 @@ CREATE TABLE tx_sgroutes_domain_model_route (
use_regular_expression tinyint(4) unsigned DEFAULT '0' NOT NULL,
source_url varchar(255) DEFAULT '' NOT NULL,
source_url_case_sensitive tinyint(4) unsigned DEFAULT '1' NOT NULL,
destination_url varchar(255) DEFAULT '' NOT NULL,
redirect_url_parameters tinyint(4) unsigned DEFAULT '0' NOT NULL,
redirect_code varchar(255) DEFAULT '301' NOT NULL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment