Skip to content

Commit 7068f49

Browse files
committed
fix(profile): ensure extractTransactionSegment never returns numeric segments
The fallback path was returning numeric segments when all other segments were placeholders or numeric. Now the fallback also filters out numeric and placeholder patterns, defaulting to 'txn' if nothing meaningful found. Fixes flaky property-based test 'does not return purely numeric segments'.
1 parent 456ebf5 commit 7068f49

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lib/transaction-alias.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ export function extractTransactionSegment(transaction: string): string {
6060
return segment.replace(/[-_]/g, "").toLowerCase();
6161
}
6262

63-
// Fallback: use first non-empty segment if no meaningful one found
64-
const firstSegment = segments.find((s) => s.length > 0);
63+
// Fallback: use first non-empty, non-numeric segment if no meaningful one found
64+
const firstSegment = segments.find(
65+
(s) =>
66+
s.length > 0 && !NUMERIC_PATTERN.test(s) && !PLACEHOLDER_PATTERN.test(s)
67+
);
6568
return firstSegment?.replace(/[-_]/g, "").toLowerCase() ?? "txn";
6669
}
6770

0 commit comments

Comments
 (0)