From d5e10648dd272b39fc431a13116e7acd3ef0daef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vendula=20=C5=A0vastalov=C3=A1?= Date: Sun, 15 Oct 2023 22:09:31 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20bug=20in=20function=20?= =?UTF-8?q?for=20removing=20suffix=20from=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/ACKLocalizationCore/ACKLocalization.swift | 3 +-- Tests/ACKLocalizationCoreTests/ACKLocalizationTests.swift | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Sources/ACKLocalizationCore/ACKLocalization.swift b/Sources/ACKLocalizationCore/ACKLocalization.swift index 45df297..065ce97 100644 --- a/Sources/ACKLocalizationCore/ACKLocalization.swift +++ b/Sources/ACKLocalizationCore/ACKLocalization.swift @@ -462,8 +462,7 @@ public final class ACKLocalization { extension String { func removingSuffix(_ suffix: String) -> String { guard hasSuffix(suffix) else { return self } - - return String(self[...index(endIndex, offsetBy: -suffix.count)]) + return String(dropLast(suffix.count)) } } diff --git a/Tests/ACKLocalizationCoreTests/ACKLocalizationTests.swift b/Tests/ACKLocalizationCoreTests/ACKLocalizationTests.swift index 33bbe31..7a13e7b 100644 --- a/Tests/ACKLocalizationCoreTests/ACKLocalizationTests.swift +++ b/Tests/ACKLocalizationCoreTests/ACKLocalizationTests.swift @@ -1,4 +1,4 @@ -import ACKLocalizationCore +@testable import ACKLocalizationCore import XCTest final class ACKLocalizationTests: XCTestCase { @@ -40,4 +40,9 @@ final class ACKLocalizationTests: XCTestCase { ] XCTAssertNoThrow(try localization.checkDuplicateKeys(form: locRow)) } + + func testRemovingSuffix() { + var fileName = "Localizable.strings" + XCTAssertEqual("Localizable", fileName.removingSuffix(".strings")) + } } From 7c83356ba468e466c5e682eea4079f75edebd703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Olejn=C3=ADk?= Date: Mon, 16 Oct 2023 12:06:28 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 449f617..8016f14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ ## master +### Fixed + +- Incorrect file name when specified with _.strings_ suffix ([#39](https://github.com/AckeeCZ/ACKLocalization/pull/39), kudos to @vendulasvastal) + ## 1.6.0 ### Added