Skip to content

Commit

Permalink
add profile options only for supported browsers
Browse files Browse the repository at this point in the history
Updates to `getProfileOption` method now only returns a valid profile
option string array for supported browsers, returns nil otherwise. This
will keep the browser command practically the same when trying to launch
with unsupported browsers.
  • Loading branch information
bhedavivek authored and johnste committed Aug 11, 2020
1 parent 2dc2164 commit e47de82
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Finicky/Finicky/Browsers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ public func getBrowserCommand(_ browserOpts: BrowserOpts, url: URL) -> [String]
}

if let profile = browserOpts.profile, let bundleId: String = browserOpts.bundleId {
command.append("-n")
let profileOption: [String] = getProfileOption(bundleId: bundleId, profile: profile)
command.append("--args")
command.append(contentsOf: profileOption)
if let profileOption: [String] = getProfileOption(bundleId: bundleId, profile: profile) {
command.append("-n")
command.append("--args")
command.append(contentsOf: profileOption)
}
}

command.append(url.absoluteString)

return command
}

private func getProfileOption(bundleId: String, profile: String) -> [String] {
var profileOption: [String] {
private func getProfileOption(bundleId: String, profile: String) -> [String]? {
var profileOption: [String]? {
switch bundleId.lowercased() {
case Browser.Brave.rawValue: return ["--profile-directory=\(profile)"]
case Browser.BraveDev.rawValue: return ["--profile-directory=\(profile)"]
Expand All @@ -51,7 +52,7 @@ private func getProfileOption(bundleId: String, profile: String) -> [String] {
// case Browser.Firefox.rawValue: return ["-P", profile]
// case Browser.FirefoxDeveloperEdition.rawValue: return ["-P", profile]

default: return [""]
default: return nil
}
}
return profileOption
Expand Down

0 comments on commit e47de82

Please sign in to comment.