1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 20:10:08 +02:00

🐛 Ensure app can handle interactions with path w/ spaces (#74)

This commit is contained in:
2021-12-23 13:27:19 +01:00
parent 6646ceda76
commit 5af1f09ee1
4 changed files with 23 additions and 8 deletions

View File

@ -34,7 +34,7 @@ class Application {
(This will open the app if it isn't open yet.)
*/
@objc public func openDirectory(file: String) {
return Shell.run("/usr/bin/open -a \"\(name)\" \(file)")
return Shell.run("/usr/bin/open -a \"\(name)\" \"\(file)\"")
}
/** Checks if the app is installed. */

View File

@ -167,11 +167,12 @@ class Valet {
}
public func determineSecured(_ tld: String) {
secured = Shell.fileExists("~/.config/valet/Certificates/\(self.name!).\(tld).key")
let name = self.name!.replacingOccurrences(of: " ", with: "\\ ")
secured = Shell.fileExists("~/.config/valet/Certificates/\(name).\(tld).key")
}
public func determineDriver() {
let driver = Shell.pipe("cd \(absolutePath!) && valet which", requiresPath: true)
let driver = Shell.pipe("cd \"\(absolutePath!)\" && valet which", requiresPath: true)
if driver.contains("This site is served by") {
self.driver = driver
// TODO: Use a regular expression to retrieve the driver instead?

View File

@ -171,7 +171,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
let originalSecureStatus = selectedSite!.secured
let action = selectedSite!.secured ? "unsecure" : "secure"
let selectedSite = selectedSite!
let command = "cd \(selectedSite.absolutePath!) && sudo \(Paths.valet) \(action) && exit;"
let command = "cd '\(selectedSite.absolutePath!)' && sudo \(Paths.valet) \(action) && exit;"
waitAndExecute {
Shell.run(command, requiresPath: true)
@ -204,16 +204,20 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
@objc public func openInBrowser() {
let prefix = selectedSite!.secured ? "https://" : "http://"
let url = "\(prefix)\(selectedSite!.name!).\(Valet.shared.config.tld)"
NSWorkspace.shared.open(URL(string: url)!)
let url = URL(string: "\(prefix)\(selectedSite!.name!).\(Valet.shared.config.tld)")
if url != nil {
NSWorkspace.shared.open(url!)
} else {
warnAboutInvalidFolderAction()
}
}
@objc public func openInFinder() {
Shell.run("open \(selectedSite!.absolutePath!)")
Shell.run("open '\(selectedSite!.absolutePath!)'")
}
@objc public func openInTerminal() {
Shell.run("open -b com.apple.terminal \(selectedSite!.absolutePath!)")
Shell.run("open -b com.apple.terminal '\(selectedSite!.absolutePath!)'")
}
@objc public func unlinkSite() {
@ -239,6 +243,13 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
)
}
private func warnAboutInvalidFolderAction() {
_ = Alert.present(
messageText: "site_list.alert.invalid_folder_name".localized,
informativeText: "site_list.alert.invalid_folder_name_desc".localized
)
}
// MARK: - (Search) Text Field Delegate
func searchedFor(text: String) {

View File

@ -74,6 +74,9 @@
"site_list.detected_apps" = "Detected Applications";
"site_list.system_apps" = "System Applications";
"site_list.alert.invalid_folder_name" = "Invalid folder name";
"site_list.alert.invalid_folder_name_desc" = "This folder could not be resolved to a valid URL. This is usually because theres a space in the folder name. Please rename the folder, reload the list of sites, and try again.";
// EDITORS
"editors.alert.try_again" = "Try Again";