File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public final class SentryTraceHeader {
1818 // Use numbered capture groups for Android API level < 26 compatibility
1919 private static final Pattern SENTRY_TRACEPARENT_HEADER_REGEX =
2020 Pattern .compile (
21- "^[ \\ t]*([0-9a-f]{32})-([0-9a-f]{16})(-[01])?[ \ \ t]*$" , Pattern .CASE_INSENSITIVE );
21+ "^[ \t ]*([0-9a-f]{32})-([0-9a-f]{16})(-[01])?[ \t ]*$" , Pattern .CASE_INSENSITIVE );
2222
2323 public SentryTraceHeader (
2424 final @ NotNull SentryId traceId ,
Original file line number Diff line number Diff line change @@ -132,6 +132,26 @@ class SentryTraceHeaderTest {
132132 assertNull(header.isSampled)
133133 }
134134
135+ @Test
136+ fun `handles header without sampling decision and leading whitespace` () {
137+ val sentryId = SentryId ()
138+ val spanId = SpanId ()
139+ val header = SentryTraceHeader (" \t $sentryId -$spanId " )
140+ assertEquals(sentryId, header.traceId)
141+ assertEquals(spanId, header.spanId)
142+ assertNull(header.isSampled)
143+ }
144+
145+ @Test
146+ fun `handles header without sampling decision and trailing whitespace` () {
147+ val sentryId = SentryId ()
148+ val spanId = SpanId ()
149+ val header = SentryTraceHeader (" $sentryId -$spanId \t " )
150+ assertEquals(sentryId, header.traceId)
151+ assertEquals(spanId, header.spanId)
152+ assertNull(header.isSampled)
153+ }
154+
135155 @Test
136156 fun `when sampling decision is not made, getValue returns header with traceId and spanId` () {
137157 val sentryId = SentryId ()
You can’t perform that action at this time.
0 commit comments