Skip to content

Commit

Permalink
Fix resolving search results title
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu committed Jun 4, 2024
1 parent 648fb0f commit 59f63f3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ All notable changes to this project will be documented in this file. Take a look

### Fixed

#### Shared

* [#444](https://github.com/readium/swift-toolkit/issues/444) Fixed resolving titles of search results when the table of contents items contain fragment identifiers.

#### Navigator

* Optimized scrolling to an EPUB text-based locator if it contains a CSS selector.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Internal/Extensions/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public extension String {
guard let range = range(of: delimiter, options: [.backwards, .literal]) else {
return self
}
return String(self[...range.lowerBound])
return String(self[..<range.lowerBound])
}

/// Replaces multiple whitespaces by a single space.
Expand Down
17 changes: 17 additions & 0 deletions Tests/InternalTests/Extensions/StringTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Copyright 2024 Readium Foundation. All rights reserved.
// Use of this source code is governed by the BSD-style license
// available in the top-level LICENSE file of the project.
//

import Foundation
@testable import ReadiumInternal
import XCTest

class StringTests: XCTestCase {
func testSubstringBeforeLast() {
XCTAssertEqual("href".substringBeforeLast("#"), "href")
XCTAssertEqual("href#anchor".substringBeforeLast("#"), "href")
XCTAssertEqual("href#anchor#test".substringBeforeLast("#"), "href#anchor")
}
}

0 comments on commit 59f63f3

Please sign in to comment.