Skip to content

Commit

Permalink
Restructure check for correct uri path segment
Browse files Browse the repository at this point in the history
  • Loading branch information
gradinarufelix committed Sep 13, 2024
1 parent f4c2c07 commit fb83927
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Classes/ContentRepository/NodeTranslationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ public function translateNode(NodeInterface $sourceNode, NodeInterface $targetNo
}

foreach ($properties as $propertyName => $propertyValue) {
if ($targetNode->getProperty($propertyName) != $propertyValue) {
$targetNode->setProperty($propertyName, $propertyValue);
// Make sure the uriPathSegment is valid
if ($propertyName === 'uriPathSegment' && !preg_match('/^[a-z0-9\-]+$/i', $propertyValue)) {
$propertyValue = $this->nodeUriPathSegmentGenerator->generateUriPathSegment(null, $propertyValue);
}

// Make sure the uriPathSegment is valid
if ($targetNode->getProperty('uriPathSegment') && !preg_match('/^[a-z0-9\-]+$/i', $targetNode->getProperty('uriPathSegment'))) {
$targetNode->setProperty('uriPathSegment', $this->nodeUriPathSegmentGenerator->generateUriPathSegment(null, $targetNode->getProperty('uriPathSegment')));
if ($targetNode->getProperty($propertyName) != $propertyValue) {
$targetNode->setProperty($propertyName, $propertyValue);
}
}
}
Expand Down

0 comments on commit fb83927

Please sign in to comment.