Skip to content

Commit

Permalink
FIX: regex to catch OID between 16 to 24 caracteres (#10)
Browse files Browse the repository at this point in the history
fix: regex to catch OID between 16 to 24 caracteres
  • Loading branch information
fernandocorreia26 authored Apr 26, 2024
1 parent b28b031 commit 82802b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Support/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function sanitize(string $uri): string
[
'/\/(?<=\/)([A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12})(?=\/)?/i',
'/\/(?<=\/)([A-Z]{3}-?\d[0-9A-Z]\d{2})(?=\/)?/i',
'/\/(?<=\/)[0-9A-F]{24}(?=\/)?/i',
'/\/(?<=\/)[0-9A-F]{16,24}(?=\/)?/i',
'/\/(?<=\/)\d+(?=\/)?/',
],
[
Expand Down
2 changes: 2 additions & 0 deletions tests/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function testClearUriUuids(): void
public function testClearUriOids(): void
{
$oid = '650229807612bba4984d1fc7';
$oidShort = '65022612bba84d1f';

self::assertSame('/v1/test', Uri::sanitize('/v1/test'));
self::assertSame('/v2/test/<OID>', Uri::sanitize("/v2/test/{$oid}"));
Expand All @@ -77,5 +78,6 @@ public function testClearUriOids(): void
self::assertSame('/v6/test/<OID>/<OID>/', Uri::sanitize("/v6/test/{$oid}/{$oid}/"));
self::assertSame('/v7/test/<OID>/<OID>/<OID>', Uri::sanitize("/v7/test/{$oid}/{$oid}/{$oid}"));
self::assertSame('/v8/test/<OID>/<OID>/<OID>/', Uri::sanitize("/v8/test/{$oid}/{$oid}/{$oid}/"));
self::assertSame('/v9/test/<OID>/bar/<NUMBER>', Uri::sanitize("/v9/test/{$oidShort}/bar/12345"));
}
}

0 comments on commit 82802b5

Please sign in to comment.