Skip to content

Commit 8989796

Browse files
committed
improve: extract price in dollars when it has a single digit only (for example, $1)
1 parent d5876f3 commit 8989796

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public SeriesExtractedInfo extract(String pageUrl, RawParsedDataDto data) {
443443
candidate = StringUtils.replaceChars(candidate, ',', '.');
444444
}
445445
// "10$" -> "10"
446-
if (candidate.endsWith("$") && candidate.length() > 2) {
446+
if (candidate.endsWith("$") && candidate.length() >= 2) {
447447
candidate = candidate.substring(0, candidate.length() - 1);
448448
}
449449
try {

src/test/groovy/ru/mystamps/web/feature/series/importing/SeriesInfoExtractorServiceImplTest.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
652652
service.extractPrice(fragment) == expected
653653
where:
654654
fragment | expected
655+
'1$' | BigDecimal.ONE
655656
'10$' | BigDecimal.TEN
656657
'10 EUR' | BigDecimal.TEN
657658
'10.0 EUR' | BigDecimal.TEN

0 commit comments

Comments
 (0)