Skip to content

Commit

Permalink
fix: custom action name regex + add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ahochsteger committed May 25, 2024
1 parent 5470741 commit 0ec5b5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/lib/actions/ActionRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,16 @@ describe("ActionRegistry.registerCustomActions", () => {
contextType: "proc",
})
})
it("should ensure proper action naming", () => {
expect(() => {
actionRegistry.registerCustomActions([
{
name: "my log",
action: (_ctx, args) => args,
},
])
}).toThrow()
})
})

describe("ActionProvider", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/actions/ActionRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ActionRegistry {
}

public registerCustomActions(actions: ActionRegistration[]) {
const nameRegex = "[a-zA-Z0-9]+"
const nameRegex = "^[a-zA-Z0-9]+$"
const regex = new RegExp(nameRegex)
actions.forEach((customAction) => {
if (regex.test(customAction.name)) {
Expand Down

0 comments on commit 0ec5b5c

Please sign in to comment.