Skip to content

Commit d53b981

Browse files
committed
fix(core): Match a fixed tunnel path that ends with a slash
1 parent aa97143 commit d53b981

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎packages/core/src/utils/tunnel.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ function fnv1a(input: string): number {
353353

354354
function tunnelPathsFor(tunnelOptions: TunnelOptions, allowedDsns: Array<string>): string[] {
355355
if (tunnelOptions.path) {
356-
return [tunnelOptions.path];
356+
return [tunnelOptions.path.replace(/\/$/, '')];
357357
}
358358

359359
return allowedDsns.map(dsn => getTunnelPath(dsn)).filter((path): path is string => !!path);

‎packages/core/test/lib/utils/tunnel.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ describe('getTunnelPaths', () => {
416416
);
417417
});
418418

419+
it('matches a fixed path that ends with a slash', () => {
420+
expect(isTunnelRequest({ method: 'POST', url: '/monitor' }, { path: '/monitor/' })).toBe(true);
421+
expect(isTunnelRequest({ method: 'POST', url: '/monitor/' }, { path: '/monitor/' })).toBe(true);
422+
});
423+
419424
it('uses the managed tunnel config of the active client', () => {
420425
expect(getTunnelPaths()).toEqual([]);
421426

@@ -498,6 +503,7 @@ describe('getTunnelIgnoreSpanFilter', () => {
498503
),
499504
).toBe(true);
500505
expect(urlPathMatcher(getTunnelIgnoreSpanFilter({ path: '/monitor' }, undefined)).test('/monitor')).toBe(true);
506+
expect(urlPathMatcher(getTunnelIgnoreSpanFilter({ path: '/monitor/' }, undefined)).test('/monitor')).toBe(true);
501507
expect(
502508
urlPathMatcher(getTunnelIgnoreSpanFilter({ basePath: '/app/' }, makeDsn(TEST_DSN))).test(
503509
`/app${getTunnelPath(TEST_DSN)}`,

0 commit comments

Comments
 (0)