Skip to content

Commit

Permalink
Update Fire Button ref tests (#1987)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaresiak authored Sep 20, 2023
1 parent 8f256c3 commit 60689d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Core/FileLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ class FileLoader {
let baseName = fileUrl.deletingPathExtension().path
let ext = fileUrl.pathExtension

guard let path = bundle.path(forResource: baseName, ofType: ext) else { throw FileError.unknownFile }
var path = bundle.path(forResource: baseName, ofType: ext)
if path == nil {
let fileName = fileName.dropping(suffix: ext).dropping(suffix: ".")
path = bundle.path(forResource: fileName, ofType: ext)
}
guard let path else { throw FileError.unknownFile }
let url = URL(fileURLWithPath: path)
guard let data = try? Data(contentsOf: url, options: [.mappedIfSafe]) else { throw FileError.invalidFileContents }
return data
Expand Down
7 changes: 6 additions & 1 deletion DuckDuckGoTests/FireButtonReferenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ final class FireButtonReferenceTests: XCTestCase {
}

private func sanitizedSite(_ site: String) -> String {
let url = URL(string: site)!
let url: URL
if site.hasPrefix("http") {
url = URL(string: site)!
} else {
url = URL(string: "https://" + site)!
}
return url.host!
}

Expand Down

0 comments on commit 60689d5

Please sign in to comment.