File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
packages/browser/src/integrations Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ function _enhanceEventWithInitialFrame(
171
171
172
172
const colno = column ;
173
173
const lineno = line ;
174
- const filename = isString ( url ) && url . length > 0 ? url : getLocationHref ( ) ;
174
+ const filename = getFilenameFromUrl ( url ) ?? getLocationHref ( ) ;
175
175
176
176
// event.exception.values[0].stacktrace.frames
177
177
if ( ev0sf . length === 0 ) {
@@ -199,3 +199,20 @@ function getOptions(): { stackParser: StackParser; attachStacktrace?: boolean }
199
199
} ;
200
200
return options ;
201
201
}
202
+
203
+ function getFilenameFromUrl ( url : string | undefined ) : string | undefined {
204
+ if ( ! isString ( url ) || url . length === 0 ) {
205
+ return undefined ;
206
+ }
207
+
208
+ // stack frame urls can be data urls, for example when initializing a Worker with a base64 encoded script
209
+ // in this case we just show the data prefix and mime type to avoid too long raw data urls
210
+ if ( url . startsWith ( 'data:' ) ) {
211
+ const match = url . match ( / ^ d a t a : ( [ ^ ; ] + ) / ) ;
212
+ const mimeType = match ? match [ 1 ] : 'text/javascript' ;
213
+ const isBase64 = url . includes ( 'base64,' ) ;
214
+ return `<data:${ mimeType } ${ isBase64 ? ',base64' : '' } >` ;
215
+ }
216
+
217
+ return url . slice ( 0 , 1024 ) ;
218
+ }
You can’t perform that action at this time.
0 commit comments