From 0d464b7a9276cbdb8f979ea670b96bd4c851ac88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AD=99=E5=A8=87?=
Date: Sat, 20 Jul 2024 20:38:54 +0800
Subject: [PATCH] No replacement if target string is empty. #23
---
lib/rules/rule_replace.dart | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/rules/rule_replace.dart b/lib/rules/rule_replace.dart
index 1e0bf45..c07aec5 100644
--- a/lib/rules/rule_replace.dart
+++ b/lib/rules/rule_replace.dart
@@ -22,6 +22,10 @@ class RuleReplace implements Rule {
@override
Future newName(String oldName, {FileMetadata? metadata}) async {
+ if (targetString.isEmpty) {
+ return oldName;
+ }
+
if (withMetadata && metadata == null) {
throw ArgumentError(L10n.current.metadataParserNotProvided);
}