Skip to content

Commit 1244a25

Browse files
authored
Merge pull request #12 from tgalopin/normalize-controllers-names
Normalize Stimulus controller names
2 parents 8a81bb4 + 5a005f6 commit 1244a25

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export function startStimulusApp(context) {
2626
}
2727

2828
symfonyControllers[controllerName].then((module) => {
29+
// Normalize the controller name: remove the initial @ and use Stimulus format
30+
controllerName = controllerName.substr(1).replace(/_/g, "-").replace(/\//g, "--");
31+
2932
application.register(controllerName, module.default);
3033
});
3134
}

test/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ describe('startStimulusApp', () => {
1919
await new Promise(setImmediate);
2020

2121
expect(app.router.modules.length).toBe(1);
22-
expect(app.router.modules[0].definition.identifier).toBe('@symfony/mock-module/mock-controller');
22+
expect(app.router.modules[0].definition.identifier).toBe('symfony--mock-module--mock-controller');
2323
});
2424
});

0 commit comments

Comments
 (0)