Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ All notable changes to this project will be documented in this file. Take a look

### Fixed

#### Streamer

* [#639](https://github.com/readium/swift-toolkit/issues/639) Optimized the opening of really large LCP protected publications.

#### Navigator

* [#70](https://github.com/readium/swift-toolkit/issues/70) Fixed restoring the reading progression with RTL EPUB.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Navigator/Audiobook/PublicationMediaLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class PublicationMediaLoader: NSObject, AVAssetResourceLoaderDelegate, Log
dispatchPrecondition(condition: .onQueue(queue))

let href = href.anyURL.normalized
if let res = resources[equivalent: href] {
if let res = resources[href] {
return res
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Navigator/EPUB/EPUBNavigatorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ open class EPUBNavigatorViewController: InputObservableViewController,
: max(firstPositionIndex, Int(ceil(lastProgressionInLastResource * Double(positionsOfLastResource.count - 1))) - 1)

location = await positionsOfFirstResource[firstPositionIndex].copy(
title: tableOfContentsTitleByHref[equivalent: link.url()],
title: tableOfContentsTitleByHref[link.url()],
locations: { $0.progression = firstProgressionInFirstResource }
)

Expand Down
12 changes: 0 additions & 12 deletions Sources/Shared/Toolkit/URL/URLProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,3 @@ private extension String {
return segments.joined(separator: "/")
}
}

public extension Dictionary where Key: URLProtocol {
/// Returns the value of the first key matching `key` after normalization.
subscript<T: URLConvertible>(equivalent key: T) -> Value? {
for (k, v) in self {
if k.isEquivalentTo(key) {
return v
}
}
return nil
}
}
2 changes: 1 addition & 1 deletion Sources/Streamer/Parser/Audio/AudioParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public final class AudioParser: PublicationParser {
container.entries
.compactMap { url -> (AnyURL, Format)? in
guard
let format = formats[equivalent: url],
let format = formats[url],
format.conformsToAny(audioSpecifications)
else {
return nil
Expand Down
1 change: 1 addition & 0 deletions Sources/Streamer/Parser/EPUB/EPUBEncryptionParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ final class EPUBEncryptionParser: Loggable {
let algorithm = encryptedDataElement.firstChild(xpath: "enc:EncryptionMethod")?.attr("Algorithm"),
let resourceURI = encryptedDataElement.firstChild(xpath: "enc:CipherData/enc:CipherReference")?.attr("URI")
.flatMap(RelativeURL.init(epubHREF:))
.map(\.normalized)
else {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Streamer/Parser/EPUB/OPFParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ final class OPFParser: Loggable {
private func makeLink(manifestItem: ReadiumFuzi.XMLElement, spineItem: ReadiumFuzi.XMLElement?, isCover: Bool) -> Link? {
guard
let relativeHref = manifestItem.attr("href").flatMap(RelativeURL.init(epubHREF:)),
let href = baseURL.resolve(relativeHref)
let href = baseURL.resolve(relativeHref)?.normalized
else {
return nil
}
Expand All @@ -212,7 +212,7 @@ final class OPFParser: Loggable {

var properties = parseStringProperties(stringProperties)

if let encryption = encryptions[equivalent: href]?.json, !encryption.isEmpty {
if let encryption = encryptions[href]?.json, !encryption.isEmpty {
properties["encrypted"] = encryption
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ final class EPUBDeobfuscator {
func deobfuscate(resource: Resource, at href: AnyURL) -> Resource {
// Checks if the resource is obfuscated with a known algorithm.
guard
let href = href.relativeURL,
let href = href.relativeURL?.normalized,
!publicationId.isEmpty, publicationId != "urn:uuid:",
let algorithmId = encryptions[equivalent: href]?.algorithm,
let algorithmId = encryptions[href]?.algorithm,
let algorithm = algorithms.first(withIdentifier: algorithmId)
else {
return resource
Expand Down
2 changes: 1 addition & 1 deletion Sources/Streamer/Parser/Image/ImageParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public final class ImageParser: PublicationParser {
container.entries
.compactMap { url -> (AnyURL, Format)? in
guard
let format = formats[equivalent: url],
let format = formats[url],
format.conformsToAny(bitmapSpecifications)
else {
return nil
Expand Down