feat-insert-service (#5)
Reviewed-on: http://catelliub.zapto.org:3000/brontomark/flux/pulls/5 Co-authored-by: mark-cachy <marco@catelli.it> Co-committed-by: mark-cachy <marco@catelli.it>
This commit is contained in:
@@ -19,4 +19,24 @@ extension MyStringExtensions on String? {
|
||||
})
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
String fileExtension() {
|
||||
if (this == null || this!.trim().isEmpty) return '';
|
||||
|
||||
final parts = this!.split('.');
|
||||
if (parts.length < 2) return ''; // Nessuna estensione trovata
|
||||
|
||||
return parts.last.toLowerCase();
|
||||
}
|
||||
|
||||
String fileNameWithoutExtension() {
|
||||
if (this == null || this!.trim().isEmpty) return '';
|
||||
this!.replaceAll(RegExp(r'[^a-zA-Z0-9\.\-]'), '_');
|
||||
final parts = this!.split('.');
|
||||
if (parts.length < 2) return this!; // Nessuna estensione trovata
|
||||
|
||||
return parts
|
||||
.sublist(0, parts.length - 1)
|
||||
.join('.'); // Ritorna tutto tranne l'ultima parte
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user