Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6862e0c

Browse filesBrowse files
cursoragentclaude
andcommitted
fix: Revert URLSearchParams in getReportDialogEndpoint and restore supportsNativeFetch native check
- getReportDialogEndpoint: Revert to manual string concatenation to preserve unencoded DSN in query string, maintaining backward compatibility - supportsNativeFetch: Restore isNativeFunction check and iframe sandbox fallback to properly detect native vs polyfilled fetch implementations Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f5376c5 commit 6862e0c
Copy full SHA for 6862e0c

2 files changed

+46-9Lines changed: 46 additions & 9 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/core/src/api.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/api.ts
+15-8Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,32 @@ export function getReportDialogEndpoint(dsnLike: DsnLike, dialogOptions: ReportD
5353
}
5454

5555
const endpoint = `${getBaseApiEndpoint(dsn)}embed/error-page/`;
56-
const params = new URLSearchParams({ dsn: dsnToString(dsn) });
5756

57+
let encodedOptions = `dsn=${dsnToString(dsn)}`;
5858
for (const key in dialogOptions) {
59-
if (key === 'dsn' || key === 'onClose') {
59+
if (key === 'dsn') {
60+
continue;
61+
}
62+
63+
if (key === 'onClose') {
6064
continue;
6165
}
6266

6367
if (key === 'user') {
6468
const user = dialogOptions.user;
65-
if (user?.name) {
66-
params.set('name', user.name);
69+
if (!user) {
70+
continue;
71+
}
72+
if (user.name) {
73+
encodedOptions += `&name=${encodeURIComponent(user.name)}`;
6774
}
68-
if (user?.email) {
69-
params.set('email', user.email);
75+
if (user.email) {
76+
encodedOptions += `&email=${encodeURIComponent(user.email)}`;
7077
}
7178
} else {
72-
params.set(key, dialogOptions[key] as string);
79+
encodedOptions += `&${encodeURIComponent(key)}=${encodeURIComponent(dialogOptions[key] as string)}`;
7380
}
7481
}
7582

76-
return `${endpoint}?${params.toString()}`;
83+
return `${endpoint}?${encodedOptions}`;
7784
}
Collapse file

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

Copy file name to clipboardExpand all lines: packages/core/src/utils/supports.ts
+31-1Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,37 @@ export function supportsNativeFetch(): boolean {
108108
return true;
109109
}
110110

111-
return _isFetchSupported();
111+
if (!_isFetchSupported()) {
112+
return false;
113+
}
114+
115+
// Fast path to avoid DOM I/O
116+
// eslint-disable-next-line @typescript-eslint/unbound-method
117+
if (isNativeFunction(WINDOW.fetch)) {
118+
return true;
119+
}
120+
121+
// window.fetch is implemented, but is polyfilled or already wrapped (e.g: by a chrome extension)
122+
// so create a "pure" iframe to see if that has native fetch
123+
let result = false;
124+
const doc = WINDOW.document;
125+
// eslint-disable-next-line deprecation/deprecation
126+
if (doc && typeof (doc.createElement as unknown) === 'function') {
127+
try {
128+
const sandbox = doc.createElement('iframe');
129+
sandbox.hidden = true;
130+
doc.head.appendChild(sandbox);
131+
if (sandbox.contentWindow?.fetch) {
132+
// eslint-disable-next-line @typescript-eslint/unbound-method
133+
result = isNativeFunction(sandbox.contentWindow.fetch);
134+
}
135+
doc.head.removeChild(sandbox);
136+
} catch (err) {
137+
DEBUG_BUILD && debug.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
138+
}
139+
}
140+
141+
return result;
112142
}
113143

114144
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.