@@ -124,13 +124,10 @@ function computeStackTraceFromStackProp(ex: any): StackTrace | null {
124
124
// Arpad: Working with the regexp above is super painful. it is quite a hack, but just stripping the `address at `
125
125
// prefix here seems like the quickest solution for now.
126
126
let url = parts [ 2 ] && parts [ 2 ] . indexOf ( 'address at ' ) === 0 ? parts [ 2 ] . substr ( 'address at ' . length ) : parts [ 2 ] ;
127
-
128
127
// Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now
129
128
// would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)
130
129
let func = parts [ 1 ] || UNKNOWN_FUNCTION ;
131
- if ( isSafariExtension ( func ) || isSafariWebExtension ( func ) ) {
132
- [ func , url ] = extractSafariExtensionDetails ( func , url ) ;
133
- }
130
+ [ func , url ] = extractSafariExtensionDetails ( func , url ) ;
134
131
135
132
element = {
136
133
url,
@@ -165,10 +162,7 @@ function computeStackTraceFromStackProp(ex: any): StackTrace | null {
165
162
166
163
let url = parts [ 3 ] ;
167
164
let func = parts [ 1 ] || UNKNOWN_FUNCTION ;
168
-
169
- if ( isSafariExtension ( func ) || isSafariWebExtension ( func ) ) {
170
- [ func , url ] = extractSafariExtensionDetails ( func , url ) ;
171
- }
165
+ [ func , url ] = extractSafariExtensionDetails ( func , url ) ;
172
166
173
167
element = {
174
168
url,
@@ -254,13 +248,36 @@ function computeStackTraceFromStacktraceProp(ex: any): StackTrace | null {
254
248
} ;
255
249
}
256
250
257
- const isSafariExtension = ( func : string ) : boolean => func . indexOf ( 'safari-extension' ) !== - 1 ;
258
- const isSafariWebExtension = ( func : string ) : boolean => func . indexOf ( 'safari-web-extension' ) !== - 1 ;
251
+ /**
252
+ * Safari web extensions, starting version unknown, can produce "frames-only" stacktraces.
253
+ * What it means, is that instead of format like:
254
+ *
255
+ * Error: wat
256
+ * at function@url:row:col
257
+ * at function@url:row:col
258
+ * at function@url:row:col
259
+ *
260
+ * it produces something like:
261
+ *
262
+ * function@url:row:col
263
+ * function@url:row:col
264
+ * function@url:row:col
265
+ *
266
+ * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.
267
+ * This function is extracted so that we can use it in both places without duplicating the logic.
268
+ * Unfortunatelly "just" changing RegExp is too complicated now and making it pass all tests
269
+ * and fix this case seems like an impossible, or at least way too time-consuming task.
270
+ */
259
271
const extractSafariExtensionDetails = ( func : string , url : string ) : [ string , string ] => {
260
- return [
261
- func . indexOf ( '@' ) !== - 1 ? func . split ( '@' ) [ 0 ] : UNKNOWN_FUNCTION ,
262
- isSafariExtension ( func ) ? `safari-extension:${ url } ` : `safari-web-extension:${ url } ` ,
263
- ] ;
272
+ const isSafariExtension = func . indexOf ( 'safari-extension' ) !== - 1 ;
273
+ const isSafariWebExtension = func . indexOf ( 'safari-web-extension' ) !== - 1 ;
274
+
275
+ return isSafariExtension || isSafariWebExtension
276
+ ? [
277
+ func . indexOf ( '@' ) !== - 1 ? func . split ( '@' ) [ 0 ] : UNKNOWN_FUNCTION ,
278
+ isSafariExtension ? `safari-extension:${ url } ` : `safari-web-extension:${ url } ` ,
279
+ ]
280
+ : [ func , url ] ;
264
281
} ;
265
282
266
283
/** Remove N number of frames from the stack */
0 commit comments