Skip to content

Commit e02a4c7

Browse files
authored
Revert "fix: Handle DSN qs and show better error messages (getsentry#2635)" (getsentry#2638)
This reverts commit 570cd83.
1 parent 570cd83 commit e02a4c7

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

packages/utils/src/dsn.ts

+3-14
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@ export class Dsn implements DsnComponents {
7272
projectId = split.pop() as string;
7373
}
7474

75-
if (projectId) {
76-
const projectMatch = projectId.match(/^\d+/);
77-
if (projectMatch) {
78-
projectId = projectMatch[0];
79-
}
80-
}
81-
8275
this._fromComponents({ host, pass, path, projectId, port, protocol: protocol as DsnProtocol, user });
8376
}
8477

@@ -97,20 +90,16 @@ export class Dsn implements DsnComponents {
9790
private _validate(): void {
9891
['protocol', 'user', 'host', 'projectId'].forEach(component => {
9992
if (!this[component as keyof DsnComponents]) {
100-
throw new SentryError(`${ERROR_MESSAGE}: ${component} missing`);
93+
throw new SentryError(ERROR_MESSAGE);
10194
}
10295
});
10396

104-
if (!this.projectId.match(/^\d+$/)) {
105-
throw new SentryError(`${ERROR_MESSAGE}: Invalid projectId ${this.projectId}`);
106-
}
107-
10897
if (this.protocol !== 'http' && this.protocol !== 'https') {
109-
throw new SentryError(`${ERROR_MESSAGE}: Invalid protocol ${this.protocol}`);
98+
throw new SentryError(ERROR_MESSAGE);
11099
}
111100

112101
if (this.port && isNaN(parseInt(this.port, 10))) {
113-
throw new SentryError(`${ERROR_MESSAGE}: Invalid port ${this.port}`);
102+
throw new SentryError(ERROR_MESSAGE);
114103
}
115104
}
116105
}

packages/utils/test/dsn.test.ts

+3-15
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ describe('Dsn', () => {
1717
expect(dsn.pass).toBe('xyz');
1818
expect(dsn.host).toBe('sentry.io');
1919
expect(dsn.port).toBe('1234');
20-
expect(dsn.path).toBe('');
2120
expect(dsn.projectId).toBe('123');
21+
expect(dsn.path).toBe('');
2222
});
2323

2424
test('applies partial components', () => {
@@ -33,8 +33,8 @@ describe('Dsn', () => {
3333
expect(dsn.pass).toBe('');
3434
expect(dsn.host).toBe('sentry.io');
3535
expect(dsn.port).toBe('');
36-
expect(dsn.path).toBe('');
3736
expect(dsn.projectId).toBe('123');
37+
expect(dsn.path).toBe('');
3838
});
3939

4040
test('throws for missing components', () => {
@@ -107,8 +107,8 @@ describe('Dsn', () => {
107107
expect(dsn.pass).toBe('xyz');
108108
expect(dsn.host).toBe('sentry.io');
109109
expect(dsn.port).toBe('1234');
110-
expect(dsn.path).toBe('');
111110
expect(dsn.projectId).toBe('123');
111+
expect(dsn.path).toBe('');
112112
});
113113

114114
test('parses a valid partial Dsn', () => {
@@ -133,17 +133,6 @@ describe('Dsn', () => {
133133
expect(dsn.projectId).toBe('321');
134134
});
135135

136-
test('with a query string', () => {
137-
const dsn = new Dsn('https://abc@sentry.io/321?sample.rate=0.1&other=value');
138-
expect(dsn.protocol).toBe('https');
139-
expect(dsn.user).toBe('abc');
140-
expect(dsn.pass).toBe('');
141-
expect(dsn.host).toBe('sentry.io');
142-
expect(dsn.port).toBe('');
143-
expect(dsn.path).toBe('');
144-
expect(dsn.projectId).toBe('321');
145-
});
146-
147136
test('throws when provided invalid Dsn', () => {
148137
expect(() => new Dsn('some@random.dsn')).toThrow(SentryError);
149138
});
@@ -158,7 +147,6 @@ describe('Dsn', () => {
158147
test('throws for invalid fields', () => {
159148
expect(() => new Dsn('httpx://abc@sentry.io/123')).toThrow(SentryError);
160149
expect(() => new Dsn('httpx://abc@sentry.io:xxx/123')).toThrow(SentryError);
161-
expect(() => new Dsn('http://abc@sentry.io/abc')).toThrow(SentryError);
162150
});
163151
});
164152

0 commit comments

Comments
 (0)