Skip to content

Commit 98cf91a

Browse files
authored
Fix resolving search results title (#446)
1 parent b2d6732 commit 98cf91a

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file. Take a look
44

55
**Warning:** Features marked as *alpha* may change or be removed in a future release without notice. Use with caution.
66

7-
<!-- ## [Unreleased] -->
7+
## [Unreleased]
8+
9+
### Fixed
10+
11+
#### Shared
12+
13+
* [#444](https://github.com/readium/swift-toolkit/issues/444) Fixed resolving titles of search results when the table of contents items contain fragment identifiers.
14+
815

916
## [2.7.1]
1017

Sources/Internal/Extensions/String.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public extension String {
6767
guard let range = range(of: delimiter, options: [.backwards, .literal]) else {
6868
return self
6969
}
70-
return String(self[...range.lowerBound])
70+
return String(self[..<range.lowerBound])
7171
}
7272

7373
/// Replaces multiple whitespaces by a single space.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// Copyright 2024 Readium Foundation. All rights reserved.
3+
// Use of this source code is governed by the BSD-style license
4+
// available in the top-level LICENSE file of the project.
5+
//
6+
7+
import Foundation
8+
@testable import ReadiumInternal
9+
import XCTest
10+
11+
class StringTests: XCTestCase {
12+
func testSubstringBeforeLast() {
13+
XCTAssertEqual("href".substringBeforeLast("#"), "href")
14+
XCTAssertEqual("href#anchor".substringBeforeLast("#"), "href")
15+
XCTAssertEqual("href#anchor#test".substringBeforeLast("#"), "href#anchor")
16+
}
17+
}

0 commit comments

Comments
 (0)