@@ -17,8 +17,8 @@ describe('getCallerInfo', () => {
1717 ? `Error
1818 at Object.getCallerInfo (/unix-example-path/node_modules/next-api-decorators/dist/internals/getCallerInfo.js:9:30)
1919 at createHandler (/unix-example-path/node_modules/next-api-decorators/dist/createHandler.js:30:51)
20- at eval (webpack-internal:///(api)/./${ path } .ts :91:144)
21- at Object.(api)/./${ path } .ts (/unix-example-path/.next/server/${ path } .js:32:1)
20+ at eval (webpack-internal:///(api)/./${ path } .js :91:144)
21+ at Object.(api)/./${ path } .js (/unix-example-path/.next/server/${ path } .js:32:1)
2222 at __webpack_require__ (/unix-example-path/.next/server/webpack-api-runtime.js:33:42)
2323 at __webpack_exec__ (/unix-example-path/.next/server/${ path } .js:42:39)
2424 at /unix-example-path/.next/server/${ path } .js:43:28
@@ -28,8 +28,8 @@ describe('getCallerInfo', () => {
2828 : `Error
2929 at Object.getCallerInfo (/unix-example-path/node_modules/next-api-decorators/dist/internals/getCallerInfo.js:9:30)
3030 at createHandler (/unix-example-path/node_modules/next-api-decorators/dist/createHandler.js:30:51)
31- at eval (webpack-internal:///./${ path } .ts :91:144)
32- at Object../${ path } .ts (/unix-example-path/.next/server/${ path } .js:32:1)
31+ at eval (webpack-internal:///./${ path } .js :91:144)
32+ at Object../${ path } .js (/unix-example-path/.next/server/${ path } .js:32:1)
3333 at __webpack_require__ (/unix-example-path/.next/server/webpack-api-runtime.js:33:42)
3434 at __webpack_exec__ (/unix-example-path/.next/server/${ path } .js:42:39)
3535 at /unix-example-path/.next/server/${ path } .js:43:28
@@ -56,7 +56,7 @@ describe('getCallerInfo', () => {
5656 Object . defineProperty ( process , 'platform' , { value : 'darwin' } ) ;
5757
5858 const dir = getCallerInfo ( ) ;
59- expect ( dir ) . toStrictEqual ( [ '/unix-example-path/.next/server/ pages/api/tags/[id]' , '[[...params]].js' ] ) ;
59+ expect ( dir ) . toStrictEqual ( [ '/pages/api/tags/[id]' , '[[...params]].js' ] ) ;
6060
6161 spyError . mockRestore ( ) ;
6262 } ) ;
@@ -66,7 +66,7 @@ describe('getCallerInfo', () => {
6666 Object . defineProperty ( process , 'platform' , { value : 'darwin' } ) ;
6767
6868 const dir = getCallerInfo ( ) ;
69- expect ( dir ) . toStrictEqual ( [ '/unix-example-path/.next/server/ pages/api/tags/[id]' , '[[...params]].js' ] ) ;
69+ expect ( dir ) . toStrictEqual ( [ '/pages/api/tags/[id]' , '[[...params]].js' ] ) ;
7070
7171 spyError . mockRestore ( ) ;
7272 } ) ;
@@ -76,7 +76,7 @@ describe('getCallerInfo', () => {
7676 Object . defineProperty ( process , 'platform' , { value : 'win32' } ) ;
7777
7878 const dir = getCallerInfo ( ) ;
79- expect ( dir ) . toStrictEqual ( [ 'C:/win-example-path/.next/server /pages/api/tags/[id]' , '[[...params]].js' ] ) ;
79+ expect ( dir ) . toStrictEqual ( [ '/pages/api/tags/[id]' , '[[...params]].js' ] ) ;
8080
8181 spyError . mockRestore ( ) ;
8282 } ) ;
@@ -86,7 +86,7 @@ describe('getCallerInfo', () => {
8686 Object . defineProperty ( process , 'platform' , { value : 'win32' } ) ;
8787
8888 const dir = getCallerInfo ( ) ;
89- expect ( dir ) . toStrictEqual ( [ 'C:/win-example-path/.next/server /pages/api/tags/[id]' , '[[...params]].js' ] ) ;
89+ expect ( dir ) . toStrictEqual ( [ '/pages/api/tags/[id]' , '[[...params]].js' ] ) ;
9090
9191 spyError . mockRestore ( ) ;
9292 } ) ;
@@ -96,7 +96,7 @@ describe('getCallerInfo', () => {
9696 Object . defineProperty ( process , 'platform' , { value : 'darwin' } ) ;
9797
9898 const dir = getCallerInfo ( ) ;
99- expect ( dir ) . toStrictEqual ( [ '/unix-example-path/.next/server/ pages/api' , '[[...user]].js' ] ) ;
99+ expect ( dir ) . toStrictEqual ( [ '/pages/api' , '[[...user]].js' ] ) ;
100100
101101 spyError . mockRestore ( ) ;
102102 } ) ;
@@ -106,7 +106,7 @@ describe('getCallerInfo', () => {
106106 Object . defineProperty ( process , 'platform' , { value : 'darwin' } ) ;
107107
108108 const dir = getCallerInfo ( ) ;
109- expect ( dir ) . toStrictEqual ( [ '/unix-example-path/.next/server/ pages/api' , '[[...user]].js' ] ) ;
109+ expect ( dir ) . toStrictEqual ( [ '/pages/api' , '[[...user]].js' ] ) ;
110110
111111 spyError . mockRestore ( ) ;
112112 } ) ;
@@ -130,10 +130,41 @@ describe('getCallerInfo', () => {
130130 Object . defineProperty ( process , 'platform' , { value : 'win32' } ) ;
131131
132132 const dir = getCallerInfo ( ) ;
133- expect ( dir ) . toStrictEqual ( [
134- 'C:/Users/exampleuser/project/route-matching/.next/server/pages/api/users/deep' ,
135- '[[...params]].js'
136- ] ) ;
133+ expect ( dir ) . toStrictEqual ( [ '/pages/api/users/deep' , '[[...params]].js' ] ) ;
134+
135+ spyError . mockRestore ( ) ;
136+ } ) ;
137+
138+ test ( 'Issue #482 - Development error' , ( ) => {
139+ const spyError = mockError (
140+ 'pages/api/deep/nested/route/[[...params]]' ,
141+ undefined ,
142+ 'Error\n' +
143+ ' at Object.getCallerInfo (/unix-example-path/node_modules/next-api-decorators/dist/internals/getCallerInfo.js:9:22)\n' +
144+ ' at createHandler (/unix-example-path/node_modules/next-api-decorators/dist/createHandler.js:30:51)\n' +
145+ ' at eval (webpack-internal:///(api)/./pages/api/deep/nested/route/[[...params]].js:35:132)'
146+ ) ;
147+ Object . defineProperty ( process , 'platform' , { value : 'darwin' } ) ;
148+
149+ const dir = getCallerInfo ( ) ;
150+ expect ( dir ) . toStrictEqual ( [ '/pages/api/deep/nested/route' , '[[...params]].js' ] ) ;
151+
152+ spyError . mockRestore ( ) ;
153+ } ) ;
154+
155+ test ( 'Issue #482 - Production error' , ( ) => {
156+ const spyError = mockError (
157+ 'pages/api/deep/nested/route/[[...params]]' ,
158+ undefined ,
159+ 'Error\n' +
160+ ' at Object.getCallerInfo (/unix-example-path/node_modules/next-api-decorators/dist/internals/getCallerInfo.js:9:22)\n' +
161+ ' at createHandler (/unix-example-path/node_modules/next-api-decorators/dist/createHandler.js:30:51)\n' +
162+ ' at /unix-example-path/.next/server/pages/api/deep/nested/route/[[...params]].js:58:132'
163+ ) ;
164+ Object . defineProperty ( process , 'platform' , { value : 'darwin' } ) ;
165+
166+ const dir = getCallerInfo ( ) ;
167+ expect ( dir ) . toStrictEqual ( [ '/pages/api/deep/nested/route' , '[[...params]].js' ] ) ;
137168
138169 spyError . mockRestore ( ) ;
139170 } ) ;
0 commit comments