Skip to content

Commit bac0256

Browse files
committed
Parse the icon tag
1 parent 74b8e3e commit bac0256

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

Sources/OPDS/OPDS1Parser.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ public class OPDS1Parser: Loggable {
9393
}
9494
let feed = Feed(title: title)
9595

96+
if let iconValue = root.firstChild(tag: "icon")?.stringValue,
97+
let absolute = URLHelper.getAbsolute(href: iconValue, base: feedURL),
98+
let iconURL = URL(string: absolute)
99+
{
100+
feed.metadata.icon = iconURL
101+
}
102+
96103
if let tmpDate = root.firstChild(tag: "updated")?.stringValue,
97104
let date = tmpDate.dateFromISO8601
98105
{

Sources/Shared/OPDS/OpdsMetadata.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Foundation
99
/// OPDS metadata properties.
1010
public class OpdsMetadata {
1111
public var title: String
12+
public var icon: URL?
1213
public var numberOfItem: Int?
1314
public var itemsPerPage: Int?
1415
public var currentPage: Int?

Tests/OPDSTests/Samples/wiki_1_1.opds

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
1919

2020
<title>Unpopular Publications</title>
21+
<icon>/images/favicon.ico?t=1516986276</icon>
2122
<updated>2010-01-10T10:01:11Z</updated>
2223
<author>
2324
<name>Spec Writer</name>

Tests/OPDSTests/readium_opds1_1_test.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class readium_opds1_1_test: XCTestCase {
4747

4848
func testMetadata() {
4949
XCTAssert(feed!.metadata.title == "Unpopular Publications")
50+
XCTAssert(feed!.metadata.icon?.absoluteString == "http://test.com/images/favicon.ico?t=1516986276")
5051
// TODO: add more tests...
5152
}
5253

0 commit comments

Comments
 (0)