Skip to content

Commit

Permalink
auto add . to suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvanMo committed May 13, 2020
1 parent b8ff3f4 commit 42995b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/src/wechat_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import 'dart:io';
import 'dart:typed_data';

///[suffix] shall be started with .
class WeChatImage {
final dynamic source;
final ImageSchema schema;
Expand Down Expand Up @@ -74,7 +73,13 @@ extension _ImageSuffix on String {
/// If [suffix] is blank, then try to read from url
/// if suffix in url not found, then return jpg as default.
String readSuffix(String suffix) {
if (suffix != null && suffix.trim().isNotEmpty) return suffix;
if (suffix != null && suffix.trim().isNotEmpty) {
if (suffix.startsWith(".")) {
return suffix;
} else {
return ".$suffix";
}
}

var path = Uri.parse(this).path;
var index = path.lastIndexOf(".");
Expand Down

0 comments on commit 42995b2

Please sign in to comment.