Skip to content

Commit 624f523

Browse files
committed
fix: consistent in different code paths
1 parent 7f2c3bc commit 624f523

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

xcode/Ext-Safari/Functions.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ func validateUrl(_ urlString: String) -> Bool {
5959
logger?.error("\(#function, privacy: .public) - Invalid URL: \(urlString, privacy: .public)")
6060
return false
6161
}
62-
if
63-
(ptcl != "https:" && ptcl != "http:")
64-
|| (!path.hasSuffix(".css") && !path.hasSuffix(".js"))
65-
{
62+
if ptcl != "https:" && ptcl != "http:" {
63+
logger?.error("\(#function, privacy: .public) - Invalid URL protocol: \(urlString, privacy: .public)")
64+
return false
65+
}
66+
if !path.hasSuffix(".css") && !path.hasSuffix(".js") {
67+
logger?.error("\(#function, privacy: .public) - Invalid URL suffix: \(urlString, privacy: .public)")
6668
return false
6769
}
6870
return true
@@ -829,7 +831,7 @@ func checkForRemoteUpdates(_ optionalFilesArray: [[String: Any]] = []) -> [[Stri
829831
let currentVersion = metadata["version"]![0]
830832
let updateUrl = metadata["updateURL"]![0]
831833
// before fetching remote contents, ensure it points to a file of the same type
832-
if !updateUrl.hasSuffix(type) {continue}
834+
if !validateUrl(updateUrl) {continue}
833835
guard
834836
let remoteFileContents = getRemoteFileContents(updateUrl),
835837
let remoteFileContentsParsed = parse(remoteFileContents),
@@ -1812,7 +1814,7 @@ func getFileRemoteUpdate(_ content: String) -> [String: String] {
18121814
return ["error": "Update failed, couldn't parse remote file contents"]
18131815
}
18141816
// check if update is needed
1815-
if version >= remoteVersion {
1817+
if !isVersionNewer(version, remoteVersion) {
18161818
return ["info": "No updates found"]
18171819
}
18181820
// at this point it is known an update is available, get new code from downloadURL

0 commit comments

Comments
 (0)