platform/packages/relations/lib/src/plural.dart
Tobe O cad3b9c746 Add 'packages/relations/' from commit 'f1d7081f462d497a1d5810356132867158379e79'
git-subtree-dir: packages/relations
git-subtree-mainline: b1a6f262ea
git-subtree-split: f1d7081f46
2020-02-15 18:44:01 -05:00

21 lines
540 B
Dart

String singular(String path) {
var str = path.trim().split('/').where((str) => str.isNotEmpty).last;
if (str.endsWith('ies'))
return str.substring(0, str.length - 3) + 'y';
else if (str.endsWith('s'))
return str.substring(0, str.length - 1);
else
return str;
}
String plural(String path) {
var str = path.trim().split('/').where((str) => str.isNotEmpty).last;
if (str.endsWith('y'))
return str.substring(0, str.length - 1) + 'ies';
else if (str.endsWith('s'))
return str;
else
return str + 's';
}