Skip to content

Commit

Permalink
[TASK] Replace GeneralUtility::_GP
Browse files Browse the repository at this point in the history
  • Loading branch information
sypets committed Oct 27, 2024
1 parent abb4556 commit 1d8fea7
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Sypets\Brofix\FormEngine\CustomEvaluation;

use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Validation of input field
* tx_brofix_exclude_link_target.linktarget
Expand Down Expand Up @@ -56,12 +54,15 @@ public function deevaluateFieldValue(array $parameters): string
* Normalize linktype for domains, this should contain only
* the domain, not the scheme.
*
* @param string $value
* @param string $linkTarget
* @return string
*/
protected function normalizeLinkTarget(string $value): string
protected function normalizeLinkTarget(string $linkTarget): string
{
$formData = GeneralUtility::_GP('data');
$formData = $_POST['data'] ?? [];
if (!$formData) {
return $linkTarget;
}
$id = key($formData['tx_brofix_exclude_link_target']);
$data = $formData['tx_brofix_exclude_link_target'][$id];

Expand All @@ -70,8 +71,11 @@ protected function normalizeLinkTarget(string $value): string

if ($match === 'domain' && $linkType === 'external') {
// extract domain
$value = preg_replace('#(?:https?://)?([^/]*).*#', '$1', $value);
$linkTarget = preg_replace('#(?:https?://)?([^/]*).*#', '$1', $linkTarget);
}
return $value;
if ($match === 'exact' && $linkType === 'external' && preg_match('#^https?://#', $linkTarget) !== 1) {
$linkTarget = 'https://' . $linkTarget;
}
return $linkTarget;
}
}

0 comments on commit 1d8fea7

Please sign in to comment.