Skip to content

Commit 198dc33

Browse files
committed
refactor: extract a variable and reduce a number of magic numbers
1 parent 9479b21 commit 198dc33

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/ru/mystamps/web/feature/series/importing/SeriesInfoExtractorServiceImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ public SeriesExtractedInfo extract(String pageUrl, RawParsedDataDto data) {
437437
}
438438

439439
String prefix = "US$";
440+
String postfix = "$";
440441

441442
String[] candidates = StringUtils.split(fragment, ' ');
442443
for (String candidate : candidates) {
@@ -445,8 +446,8 @@ public SeriesExtractedInfo extract(String pageUrl, RawParsedDataDto data) {
445446
candidate = StringUtils.replaceChars(candidate, ',', '.');
446447
}
447448
// "10$" -> "10"
448-
if (candidate.endsWith("$") && candidate.length() >= 2) {
449-
candidate = candidate.substring(0, candidate.length() - 1);
449+
if (candidate.endsWith(postfix) && candidate.length() > postfix.length()) {
450+
candidate = StringUtils.substringBeforeLast(candidate, postfix);
450451
}
451452
// "US$10" -> "10"
452453
if (candidate.startsWith(prefix) && candidate.length() > prefix.length()) {

0 commit comments

Comments
 (0)