File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 9
9
10
10
* @license https://github.com/opencodeco/hyperf-metric/blob/main/LICENSE
11
11
*/
12
+
12
13
namespace Hyperf \Metric \Support ;
13
14
14
15
final class Uri
@@ -17,13 +18,15 @@ public static function sanitize(string $uri): string
17
18
{
18
19
return preg_replace (
19
20
[
21
+ '/\/(?<=\/)[ED]\d{8}\d{12}[0-9a-zA-Z]{11}(?=\/)?/ ' ,
20
22
'/\/(?<=\/)[a-f0-9]{40}(?=\/)?/i ' ,
21
23
'/\/(?<=\/)([A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12})(?=\/)?/i ' ,
22
24
'/\/(?<=\/)([A-Z]{3}-?\d[0-9A-Z]\d{2})(?=\/)?/i ' ,
23
25
'/\/(?<=\/)[0-9A-F]{16,24}(?=\/)?/i ' ,
24
26
'/\/(?<=\/)\d+(?=\/)?/ ' ,
25
27
],
26
28
[
29
+ '/<E2E-ID> ' ,
27
30
'/<SHA1> ' ,
28
31
'/<UUID> ' ,
29
32
'/<LICENSE-PLATE> ' ,
@@ -33,4 +36,4 @@ public static function sanitize(string $uri): string
33
36
'/ ' . ltrim ($ uri , '/ ' ),
34
37
);
35
38
}
36
- }
39
+ }
Original file line number Diff line number Diff line change @@ -118,4 +118,18 @@ public function testSanitizeHashsStrings(): void
118
118
self ::assertSame ('/v8/test/<SHA1>/<SHA1>/<SHA1>/ ' , Uri::sanitize ('/v8/test/141da78905dcaa7ed8d4da7c3f49a2415ebdc110/141da78905dcaa7ed8d4da7c3f49a2415ebdc110/141da78905dcaa7ed8d4da7c3f49a2415ebdc110/ ' ));
119
119
self ::assertSame ('/v8/test/<SHA1>/<SHA1>/<SHA1>/ ' , Uri::sanitize ('/v8/test/7110EDA4D09E062AA5E4A390B0A572AC0D2C0220/7110EDA4D09E062AA5E4A390B0A572AC0D2C0220/7110EDA4D09E062AA5E4A390B0A572AC0D2C0220/ ' ));
120
120
}
121
+
122
+ public function testSanitizeEndToEndId (): void
123
+ {
124
+ $ e2eid = 'E99999999202401010000abcDEF12345 ' ;
125
+
126
+ self ::assertSame ('/v1/test ' , Uri::sanitize ('/v1/test ' ));
127
+ self ::assertSame ('/v2/test/<E2E-ID> ' , Uri::sanitize ("/v2/test/ {$ e2eid }" ));
128
+ self ::assertSame ('/v3/test/<E2E-ID>/bar ' , Uri::sanitize ("/v3/test/ {$ e2eid }/bar " ));
129
+ self ::assertSame ('/v4/test/<E2E-ID>/bar/<E2E-ID>/ ' , Uri::sanitize ("/v4/test/ {$ e2eid }/bar/ {$ e2eid }/ " ));
130
+ self ::assertSame ('/v5/test/<E2E-ID>/<E2E-ID> ' , Uri::sanitize ("/v5/test/ {$ e2eid }/ {$ e2eid }" ));
131
+ self ::assertSame ('/v6/test/<E2E-ID>/<E2E-ID>/ ' , Uri::sanitize ("/v6/test/ {$ e2eid }/ {$ e2eid }/ " ));
132
+ self ::assertSame ('/v7/test/<E2E-ID>/<E2E-ID>/<E2E-ID> ' , Uri::sanitize ("/v7/test/ {$ e2eid }/ {$ e2eid }/ {$ e2eid }" ));
133
+ self ::assertSame ('/v8/test/<E2E-ID>/<E2E-ID>/<E2E-ID>/ ' , Uri::sanitize ("/v8/test/ {$ e2eid }/ {$ e2eid }/ {$ e2eid }/ " ));
134
+ }
121
135
}
You can’t perform that action at this time.
0 commit comments