Skip to content

feat: camel-case feature names in inertia middleware - #6

Merged
shavonn merged 1 commit into
mainfrom
camelcase-features
Jan 14, 2026
Merged

feat: camel-case feature names in inertia middleware#6
shavonn merged 1 commit into
mainfrom
camelcase-features

Conversation

@shavonn

@shavonn shavonn commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings January 14, 2026 01:51
@shavonn
shavonn merged commit 0458201 into main Jan 14, 2026
18 checks passed
@shavonn
shavonn deleted the camelcase-features branch January 14, 2026 01:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds automatic conversion of feature flag names from kebab-case to camelCase when sharing toggles with Inertia frontends, aligning with JavaScript naming conventions.

Changes:

  • Modified ShareTogglesWithInertia middleware to transform toggle keys using Str::camel()
  • Added comprehensive test coverage for the camelCase conversion functionality
  • Updated README documentation to reflect the camelCase usage in JavaScript

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Middleware/ShareTogglesWithInertia.php Implements camelCase transformation using Laravel's Str::camel() helper on toggle keys while preserving boolean values
tests/Feature/InertiaMiddlewareTest.php Adds three test cases covering basic sharing, key conversion, and value preservation
README.md Updates JavaScript example to use camelCase property access (flags.newCheckout) instead of bracket notation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +36
it('converts kebab-case toggle names to camelCase', function () {
config()->set('toggle.flags', [
'test-flag' => true,
'another-feature-flag' => false,
'simple' => true,
]);

$middleware = new ShareTogglesWithInertia;
$request = Request::create('/');

$shared = $middleware->share($request);

expect($shared['flags'])
->toHaveKey('testFlag')
->toHaveKey('anotherFeatureFlag')
->toHaveKey('simple')
->not->toHaveKey('test-flag')
->not->toHaveKey('another-feature-flag');
});

Copilot AI Jan 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding test coverage for edge cases with different naming conventions. While the current tests cover kebab-case conversion well, it would be beneficial to test how snake_case (e.g., 'feature_flag'), PascalCase (e.g., 'FeatureFlag'), and mixed formats are handled by Str::camel(). This ensures the behavior is consistent and predictable for various input formats that users might employ.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants