tryAppendExtension method

String tryAppendExtension (
  1. String path,
  2. String ext
)

Append a ext extension to path if appropriate.

Implementation

String tryAppendExtension(String path, String ext) {
  final re = RegExp(r'(\.[a-z]*$)|([\?;].*)$');
  return re.hasMatch(path) ? path : '$path$ext';

//2.4.0 20150226
//  abstractFileManager.prototype.tryAppendExtension = function(path, ext) {
//      return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext;
//  };
}