File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
packages/nextjs/src/utils Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -317,14 +317,23 @@ function makeWrappedMethodForGettingParameterizedPath(
317
317
origMethod : ApiPageEnsurer | PageComponentFinder ,
318
318
) : WrappedApiPageEnsurer | WrappedPageComponentFinder {
319
319
// eslint-disable-next-line @typescript-eslint/no-explicit-any
320
- const wrappedMethod = async function ( this : Server , parameterizedPath : string , ...args : any [ ] ) : Promise < any > {
320
+ const wrappedMethod = async function (
321
+ this : Server ,
322
+ parameterizedPath :
323
+ | string // `ensureAPIPage`, `findPageComponents` before nextjs 12.2.6
324
+ | { pathname : string } , // `findPageComponents` from nextjs 12.2.6 onward
325
+ ...args : any [ ]
326
+ ) : Promise < any > {
321
327
const transaction = getActiveTransaction ( ) ;
322
328
323
329
// replace specific URL with parameterized version
324
330
if ( transaction && transaction . metadata . requestPath ) {
325
331
const origPath = transaction . metadata . requestPath ;
326
- const newName = transaction . name . replace ( origPath , parameterizedPath ) ;
327
- transaction . setName ( newName , 'route' ) ;
332
+ const newPath = typeof parameterizedPath === 'string' ? parameterizedPath : parameterizedPath . pathname ;
333
+ if ( newPath ) {
334
+ const newName = transaction . name . replace ( origPath , newPath ) ;
335
+ transaction . setName ( newName , 'route' ) ;
336
+ }
328
337
}
329
338
330
339
return origMethod . call ( this , parameterizedPath , ...args ) ;
You can’t perform that action at this time.
0 commit comments