File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
packages/brisa/src/utils/response-action Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 9
9
} from 'bun:test' ;
10
10
import path from 'node:path' ;
11
11
import extendRequestContext from '@/utils/extend-request-context' ;
12
- import responseAction from '.' ;
12
+ import responseAction , { getActionFile } from '.' ;
13
13
import { getConstants } from '@/constants' ;
14
14
import { ENCRYPT_NONTEXT_PREFIX , encrypt } from '@/utils/crypto' ;
15
15
import { boldLog } from '@/utils/log/log-color' ;
@@ -847,4 +847,10 @@ describe('utils', () => {
847
847
expect ( await res . text ( ) ) . toBe ( JSON . stringify ( [ [ 'foo' , 'bar' ] ] ) ) ;
848
848
} ) ;
849
849
} ) ;
850
+
851
+ describe ( 'getActionFile' , ( ) => {
852
+ it ( 'should return the file with the .js extension to work in Node.js and Bun.js' , ( ) => {
853
+ expect ( getActionFile ( 'a1_1' ) ) . toBe ( 'a1.js' ) ;
854
+ } ) ;
855
+ } ) ;
850
856
} ) ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export default async function responseAction(req: RequestContext) {
16
16
const action =
17
17
req . headers . get ( 'x-action' ) ?? url . searchParams . get ( '_aid' ) ?? '' ;
18
18
const actionsHeaderValue = req . headers . get ( 'x-actions' ) ?? '[]' ;
19
- const actionFile = action . split ( '_' ) . at ( 0 ) ;
19
+ const actionFile = getActionFile ( action ) ;
20
20
const actionModule = await import ( join ( BUILD_DIR , 'actions' , actionFile ! ) ) ;
21
21
let resetForm = false ;
22
22
@@ -202,3 +202,7 @@ export default async function responseAction(req: RequestContext) {
202
202
203
203
return response ;
204
204
}
205
+
206
+ export function getActionFile ( action : string ) {
207
+ return action . split ( '_' ) . at ( 0 ) + '.js' ;
208
+ }
You can’t perform that action at this time.
0 commit comments