Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ relaxFnArgs(Function fn) {
capitalize(String s) => s.substring(0, 1).toUpperCase() + s.substring(1);

String camelCase(String s) {
var part = s.split('-').map((s) => s.toLowerCase());
if (part.length <= 1) return part.join();
return part.first + part.skip(1).map(capitalize).join();
var parts = s.split('-');
return parts.first.toLowerCase() + parts.skip(1).map(capitalize).join();
}

/// Returns whether or not the given identifier is a reserved word in Dart.
Expand Down
4 changes: 4 additions & 0 deletions test/utils_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ main() {
it('should lowercase strings', () {
expect(camelCase('Caps-first')).toEqual('capsFirst');
});

it('should work on empty string', () {
expect(camelCase('')).toEqual('');
});
});
}