File tree Expand file tree Collapse file tree
main/java/datadog/opentracing/decorators
test/groovy/datadog/opentracing/decorators Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ public class URLAsResourceName extends AbstractDecorator {
1111
1212 // Matches everything after the ? character.
1313 public static final Pattern QUERYSTRING = Pattern .compile ("\\ ?.*$" );
14- // Matches any path segments with numbers in them.
14+ // Matches any path segments with numbers in them. (exception for versioning: "/v1/")
1515 public static final Pattern PATH_MIXED_ALPHANUMERICS =
16- Pattern .compile ("/ (?:[^\\ /\\ d\\ ?]*[\\ d]+[^\\ /\\ ?]*)" );
16+ Pattern .compile ("(?<=/)(?![vV] \\ d{1,2}/) (?:[^\\ /\\ d\\ ?]*[\\ d]+[^\\ /\\ ?]*)" );
1717
1818 public URLAsResourceName () {
1919 super ();
@@ -60,7 +60,7 @@ private String norm(final String origin) {
6060
6161 String norm = origin ;
6262 norm = QUERYSTRING .matcher (norm ).replaceAll ("" );
63- norm = PATH_MIXED_ALPHANUMERICS .matcher (norm ).replaceAll ("/ ?" );
63+ norm = PATH_MIXED_ALPHANUMERICS .matcher (norm ).replaceAll ("?" );
6464
6565 return norm ;
6666 }
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ class URLAsResourceNameTest extends Specification {
2020
2121 where :
2222 input | output
23+ " /" | " /"
24+ " /?asdf" | " /"
2325 " /search" | " /search"
2426 " /search?" | " /search"
2527 " /search?id=100&private=true" | " /search"
@@ -52,10 +54,10 @@ class URLAsResourceNameTest extends Specification {
5254
5355 where :
5456 input | output
55- " /a1" | " /?"
56- " /1a" | " /?"
57- " /abc/-1?" | " /abc/?"
58- " /ABC/a -1/b_2/c.3/d4d/5f/6 " | " /ABC/?/?/?/?/?/?"
57+ " /a1/v2 " | " /? /?"
58+ " /v3/ 1a" | " /v3 /?"
59+ " /V01/v9/ abc/-1?" | " /V01/v9 /abc/?"
60+ " /ABC/av -1/b_2/c.3/d4d/v5f/v699/7 " | " /ABC/? /?/?/?/?/?/?"
5961 " /user/asdf123/repository/01234567-9ABC-DEF0-1234" | " /user/?/repository/?"
6062 }
6163
You can’t perform that action at this time.
0 commit comments