Retain original filename as imported profile name (#240)

This commit is contained in:
Davide De Rosa 2022-10-30 10:22:44 +01:00 committed by GitHub
parent dad6d820e9
commit 22c28de641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -49,7 +49,7 @@ extension AddHostView {
return return
} }
isNamePreset = true isNamePreset = true
profileName = url.normalizedFilename profileName = url.filename
} }
@MainActor @MainActor

View File

@ -32,11 +32,8 @@ import AppKit
#endif #endif
extension URL { extension URL {
private static let illegalCharacterFallback = "_" public var filename: String {
deletingPathExtension().lastPathComponent
public var normalizedFilename: String {
let filename = deletingPathExtension().lastPathComponent
return filename.components(separatedBy: CharacterSet.filename.inverted).joined(separator: URL.illegalCharacterFallback)
} }
@discardableResult @discardableResult