Skip to content

Commit 63d8840

Browse files
authored
feat(core): Remove hub check in isSentryRequestUrl (#11407)
1 parent e9d17d0 commit 63d8840

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
import type { Client, DsnComponents, Hub } from '@sentry/types';
1+
import type { Client, DsnComponents } from '@sentry/types';
22

33
/**
44
* Checks whether given url points to Sentry server
5-
* @param url url to verify
65
*
7-
* TODO(v8): Remove Hub fallback type
6+
* @param url url to verify
87
*/
9-
export function isSentryRequestUrl(url: string, hubOrClient: Hub | Client | undefined): boolean {
10-
const client =
11-
hubOrClient && isHub(hubOrClient)
12-
? // eslint-disable-next-line deprecation/deprecation
13-
hubOrClient.getClient()
14-
: hubOrClient;
8+
export function isSentryRequestUrl(url: string, client: Client | undefined): boolean {
159
const dsn = client && client.getDsn();
1610
const tunnel = client && client.getOptions().tunnel;
17-
1811
return checkDsn(url, dsn) || checkTunnel(url, tunnel);
1912
}
2013

@@ -33,8 +26,3 @@ function checkDsn(url: string, dsn: DsnComponents | undefined): boolean {
3326
function removeTrailingSlash(str: string): string {
3427
return str[str.length - 1] === '/' ? str.slice(0, -1) : str;
3528
}
36-
37-
function isHub(hubOrClient: Hub | Client | undefined): hubOrClient is Hub {
38-
// eslint-disable-next-line deprecation/deprecation
39-
return (hubOrClient as Hub).getClient !== undefined;
40-
}

packages/core/test/lib/utils/isSentryRequestUrl.test.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client, Hub } from '@sentry/types';
1+
import type { Client } from '@sentry/types';
22

33
import { isSentryRequestUrl } from '../../../src';
44

@@ -17,15 +17,6 @@ describe('isSentryRequestUrl', () => {
1717
getDsn: () => ({ host: dsn }),
1818
} as unknown as Client;
1919

20-
const hub = {
21-
getClient: () => {
22-
return client;
23-
},
24-
} as unknown as Hub;
25-
26-
// Works with hub passed
27-
expect(isSentryRequestUrl(url, hub)).toBe(expected);
28-
2920
// Works with client passed
3021
expect(isSentryRequestUrl(url, client)).toBe(expected);
3122
});

0 commit comments

Comments
 (0)