mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-04-28 18:39:26 -05:00
refactor: extname as string extension
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
extension MyString<T extends String> on String {
|
||||
int get toInt => int.parse(this);
|
||||
@@ -6,4 +7,15 @@ extension MyString<T extends String> on String {
|
||||
String get urldecode => Uri.decodeComponent(this);
|
||||
String get dropLineBreak => this.replaceAll('\n', '');
|
||||
String get base64ToUtf8 => utf8.decode(base64.decode(this));
|
||||
|
||||
/// Get extension by file name/path, returns `null` instead of empty string
|
||||
///
|
||||
/// 1.dart -> 'dart'
|
||||
///
|
||||
/// license -> null
|
||||
String get ext {
|
||||
final dotext = p.extension(this);
|
||||
if (dotext.isEmpty) return null;
|
||||
return dotext.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user