Skip to content

Commit 82802b5

Browse files
FIX: regex to catch OID between 16 to 24 caracteres (#10)
fix: regex to catch OID between 16 to 24 caracteres
1 parent b28b031 commit 82802b5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Support/Uri.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static function sanitize(string $uri): string
1919
[
2020
'/\/(?<=\/)([A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12})(?=\/)?/i',
2121
'/\/(?<=\/)([A-Z]{3}-?\d[0-9A-Z]\d{2})(?=\/)?/i',
22-
'/\/(?<=\/)[0-9A-F]{24}(?=\/)?/i',
22+
'/\/(?<=\/)[0-9A-F]{16,24}(?=\/)?/i',
2323
'/\/(?<=\/)\d+(?=\/)?/',
2424
],
2525
[

tests/UriTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function testClearUriUuids(): void
6868
public function testClearUriOids(): void
6969
{
7070
$oid = '650229807612bba4984d1fc7';
71+
$oidShort = '65022612bba84d1f';
7172

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

0 commit comments

Comments
 (0)