Skip to content

Commit

Permalink
Add parsing of the largest apple touch icon size
Browse files Browse the repository at this point in the history
  • Loading branch information
renssies committed Aug 8, 2019
1 parent 4d9747a commit 72414dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Ocarina/URLInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ public class URLInformation: NSCoding, Equatable {

if let appleTouchIconURLString = html.xpath("/html/head/link[@rel=\"apple-touch-icon\" and not(@sizes)]/@href").first?.text {
self.appleTouchIconURL = URL(string: appleTouchIconURLString, relativeTo: url)
} else if let appleTouchIconURLString = html.xpath("/html/head/link[@rel=\"apple-touch-icon\" and @sizes=\"180x180\"]/@href").first?.text {
self.appleTouchIconURL = URL(string: appleTouchIconURLString, relativeTo: url)
} else if let appleTouchIconURLString = html.xpath("/html/head/link[@rel=\"apple-touch-icon-precomposed\" and not(@sizes)]/@href").first?.text {
self.appleTouchIconURL = URL(string: appleTouchIconURLString, relativeTo: url)
}
Expand Down
2 changes: 1 addition & 1 deletion OcarinaTests/InformationFetchingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class InformationFetchingTests: XCTestCase {
XCTAssert(information?.type == .website, "The link should be of type website.")
XCTAssert(information?.title?.count ?? 0 > 0, "The article should have a title of at least 1 character.")
XCTAssert(information?.descriptionText?.count ?? 0 > 0, "The article should have a description of at least 1 character.")
XCTAssert(information?.imageURL == nil, "The link shouldn't have an image.")
XCTAssert(information?.imageURL != nil, "The link should have an image.")
XCTAssert(information?.faviconURL != nil, "The link should have a favicon.")
XCTAssert(information?.appleTouchIconURL != nil, "The link should have a apple touch icon.")

Expand Down

0 comments on commit 72414dc

Please sign in to comment.