Skip to content

Commit 29c0d39

Browse files
authored
upkeep: Atualiza regex para suportar novos formatos de ID e adiciona … (#33)
upkeep: Atualiza regex para suportar novos formatos de ID e adiciona código de prefixo ECOSYSTEM
1 parent 725d62d commit 29c0d39

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Support/Uri.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function sanitize(string $uri, array $uriMask = []): string
2727
'/\/(?<=\/)[0-9A-F]{16,24}(?=\/)?/i',
2828
'/\/(?<=\/)\d+(?=\/)?/',
2929
'/\/(?<=\/)R[RN]\d{16}[A-Za-z0-9]{11}/',
30-
'/\/(?<=\/)([A-Z]+(?:-[A-Z]+)*)-([0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}|[A-Z]{3}-\d{10}_\d{3})(?=\/|$)/i',
30+
'/\/(?<=\/)([A-Z]+(?:-[A-Z]+)*)-([0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}|[A-Z]{3}-\d+(?:_\d{3})?|[A-Za-z0-9-_]+)(?=\/|$)/i',
3131
],
3232
),
3333
array_merge(

tests/Cases/UriTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,19 @@ public function testClearUriPrefixedUuid(): void
184184
// Gera IDs do tipo ECOSYSTEM
185185
$generateEcosystemId = function(): string {
186186
$prefixes = ['ECOSYSTEM', 'PLATFORM', 'SERVICE', 'MODULE'];
187-
$codes = ['EPF', 'ABC', 'XYZ', 'DEF', 'GHI'];
187+
$codes = ['EPF', 'ABC', 'XYZ', 'DEF', 'GHI', 'ESF'];
188188

189189
$prefix = $prefixes[array_rand($prefixes)];
190190
$code = $codes[array_rand($codes)];
191-
$number = str_pad((string)rand(1000000000, 9999999999), 10, '0', STR_PAD_LEFT);
192-
$sequence = str_pad((string)rand(1, 999), 3, '0', STR_PAD_LEFT);
191+
$number = (string)rand(100000000, 9999999999); // 9-10 dígitos
193192

194-
return "{$prefix}-{$code}-{$number}_{$sequence}";
193+
// 50% de chance de ter sequência final
194+
if (rand(0, 1)) {
195+
$sequence = str_pad((string)rand(1, 999), 3, '0', STR_PAD_LEFT);
196+
return "{$prefix}-{$code}-{$number}_{$sequence}";
197+
}
198+
199+
return "{$prefix}-{$code}-{$number}";
195200
};
196201

197202
$randomPrefix = $generateRandomPrefix();

0 commit comments

Comments
 (0)