Skip to content

Commit

Permalink
Merge pull request #50 from sitegeist/chore-uri-path-segment
Browse files Browse the repository at this point in the history
CHORE: Restructure check for correct uri path segment
  • Loading branch information
mficzel authored Sep 20, 2024
2 parents aad7d08 + fb83927 commit 035b096
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 @@ -213,13 +213,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 035b096

Please sign in to comment.