Skip to content

Commit 5311fcb

Browse files
committed
ref(utils): dsn
1 parent fa5eeee commit 5311fcb

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

packages/core/src/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { DsnLike, SdkMetadata } from '@sentry/types';
2-
import { Dsn, makeDsn, urlEncode } from '@sentry/utils';
1+
import { Dsn, DsnLike, SdkMetadata } from '@sentry/types';
2+
import { makeDsn, urlEncode } from '@sentry/utils';
33

44
const SENTRY_API_VERSION = '7';
55

packages/core/src/baseclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Scope, Session } from '@sentry/hub';
33
import {
44
Client,
5+
Dsn,
56
Event,
67
EventHint,
78
Integration,
@@ -13,7 +14,6 @@ import {
1314
import {
1415
checkOrSetAlreadyCaught,
1516
dateTimestampInSeconds,
16-
Dsn,
1717
isPlainObject,
1818
isPrimitive,
1919
isThenable,

packages/types/src/dsn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ export interface Dsn extends DsnComponents {
3535
*
3636
* @param withPassword When set to true, the password will be included.
3737
*/
38-
toString(withPassword: boolean): string;
38+
toString(withPassword?: boolean): string;
3939
}

packages/utils/src/dsn.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
import { DsnComponents, DsnLike, DsnProtocol } from '@sentry/types';
1+
import { Dsn, DsnComponents, DsnLike, DsnProtocol } from '@sentry/types';
22

33
import { isDebugBuild } from './env';
44
import { SentryError } from './error';
55

6-
export interface Dsn extends DsnComponents {
7-
/** Protocol used to connect to Sentry. */
8-
toString(withPassword: boolean): string;
9-
}
10-
116
/** Regular expression used to parse a Dsn. */
127
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;
138

@@ -92,7 +87,7 @@ function validateDsn(dsn: Dsn): boolean {
9287
throw new SentryError(`Invalid Dsn: Invalid projectId ${projectId}`);
9388
}
9489

95-
if (isValidProtocol(protocol)) {
90+
if (!isValidProtocol(protocol)) {
9691
throw new SentryError(`Invalid Dsn: Invalid protocol ${protocol}`);
9792
}
9893

@@ -112,7 +107,7 @@ export function makeDsn(from: DsnLike): Dsn {
112107

113108
const dsn: Dsn = {
114109
...components,
115-
toString: (withPassword: boolean) => dsntoString(dsn),
110+
toString: (withPassword: boolean) => dsntoString(dsn, withPassword),
116111
};
117112

118113
return dsn;

0 commit comments

Comments
 (0)