File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ const newrelic = require('newrelic')
14
14
const fs = require ( 'node:fs' )
15
15
const path = require ( 'node:path' )
16
16
17
+ function getModulePath ( handler ) {
18
+ const lastSlashIndex = handler . lastIndexOf ( '/' ) + 1
19
+ const firstDotAfterSlash = handler . indexOf ( '.' , lastSlashIndex )
20
+ return handler . slice ( 0 , firstDotAfterSlash )
21
+ }
22
+
17
23
function getHandlerPath ( ) {
18
24
let handler
19
25
const { NEW_RELIC_LAMBDA_HANDLER } = process . env
@@ -32,8 +38,9 @@ function getHandlerPath() {
32
38
)
33
39
}
34
40
35
- const handlerToWrap = parts [ parts . length - 1 ]
36
- const moduleToImport = handler . slice ( 0 , handler . lastIndexOf ( '.' ) )
41
+ let prefixIndex = handler . lastIndexOf ( '/' ) !== - 1 ? handler . lastIndexOf ( '/' ) + 1 : 0
42
+ const handlerToWrap = handler . slice ( prefixIndex ) . split ( '.' ) . slice ( 1 ) . join ( '.' )
43
+ const moduleToImport = getModulePath ( handler )
37
44
return { moduleToImport, handlerToWrap }
38
45
}
39
46
You can’t perform that action at this time.
0 commit comments