Skip to content

Commit e7d311c

Browse files
authored
Refactor URI sanitize patterns (#4)
* fix patterns, shortening patterns and implement case-insensitive * add vscode and jetbrains ide folders into .gitignore
1 parent 253b975 commit e7d311c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.idea
2+
.vscode
13
*.cache
24
*.log
35
vendor/

src/Support/Uri.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ public static function sanitize(string $uri): string
1717
{
1818
return preg_replace(
1919
[
20-
'/\/(?<=\/)([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})(?=\/)?/',
21-
'/\/(?<=\/)[A-Za-z]{3}\d[A-Za-z]\d{2}(?=\/)?/',
22-
'/\/(?<=\/)[A-Za-z]{3}\d{4}(?=\/)?/',
23-
'/\/(?<=\/)[0-9A-Fa-f]{24}(?=\/)?/',
20+
'/\/(?<=\/)([A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12})(?=\/)?/i',
21+
'/\/(?<=\/)([A-Z]{3}-?\d[0-9A-Z]\d{2})(?=\/)?/i',
22+
'/\/(?<=\/)[0-9A-F]{24}(?=\/)?/i',
2423
'/\/(?<=\/)\d+(?=\/)?/',
2524
],
2625
[
2726
'/<UUID>',
2827
'/<LICENSE-PLATE>',
29-
'/<LICENSE-PLATE>',
3028
'/<OID>',
3129
'/<NUMBER>',
3230
],

0 commit comments

Comments
 (0)