Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

IBX-6202: Fixed url alias grouping #248

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/Repository/NameSchema/NameSchemaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ protected function tokenParts(string $token): array
*/
protected function filterNameSchema(string $nameSchema): array
{
$retNamePattern = '';
$retNamePattern = $nameSchema;
$foundGroups = preg_match_all('/\((.+)\)/U', $nameSchema, $groupArray);
$groupLookupTable = [];

Expand All @@ -341,7 +341,7 @@ protected function filterNameSchema(string $nameSchema): array

// Insert the group with its placeholder token
/** @var string $retNamePattern */
$retNamePattern = str_replace($group, $metaToken, $nameSchema);
$retNamePattern = str_replace($group, $metaToken, $retNamePattern);

// Remove the pattern "(" ")" from the tokens
$group = str_replace(['(', ')'], '', $group);
Expand Down
3 changes: 1 addition & 2 deletions src/lib/Repository/NameSchema/SchemaIdentifierExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class SchemaIdentifierExtractor implements SchemaIdentifierExtractorInterf
*/
public function extract(string $schemaString): array
{
$allTokens = '/<([^>-]+)>/';
$allTokens = '/[<|\(]?([\w\d:_]+)[>\)]?/';

if (false === preg_match_all($allTokens, $schemaString, $matches)) {
return [];
Expand All @@ -46,7 +46,6 @@ public function extract(string $schemaString): array
$strategy = 'field';
}

$token = preg_replace('/[()<>\[\]]/', '', $token);
$strategyIdentifiers[$strategy][] = $token;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public function getDataForTestExtract(): iterable
'custom' => ['bar'],
],
];

$schemaString = '<description|(<attribute:mouse_type> <attribute:mouse_weight>)>';
yield $schemaString => [
$schemaString,
[
'field' => ['description'],
'attribute' => ['mouse_type', 'mouse_weight'],
],
];
}

protected function setUp(): void
Expand All @@ -99,6 +108,7 @@ protected function setUp(): void
*/
public function testExtract(string $schemaString, array $expectedStrategyIdentifierMap): void
{
self::assertSame($expectedStrategyIdentifierMap, $this->extractor->extract($schemaString));
$extracted = $this->extractor->extract($schemaString);
self::assertSame($expectedStrategyIdentifierMap, $extracted);
}
}