Skip to content
Permalink
Browse files

Trim URL string whitespace and newlines

If the URL input in the Open URL window contains a trailing newline the open operation fails. This is a common scenario e.g. when selecting (triple clicking) and copying an entire line that only consists of an URL.
  • Loading branch information...
anohren authored and lhc70000 committed Feb 16, 2019
1 parent 532892f commit 46495c3ea081e57b74b7a69808defdd669995cb2
Showing with 2 additions and 1 deletion.
  1. +2 −1 iina/OpenURLWindowController.swift
@@ -74,7 +74,8 @@ class OpenURLWindowController: NSWindowController, NSTextFieldDelegate, NSContro
guard !urlField.stringValue.isEmpty else { return (nil, false) }
let username = usernameField.stringValue
let password = passwordField.stringValue
guard var urlValue = urlField.stringValue.addingPercentEncoding(withAllowedCharacters: .urlAllowed) else {
let trimmedUrlString = urlField.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
guard var urlValue = trimmedUrlString.addingPercentEncoding(withAllowedCharacters: .urlAllowed) else {
return (nil, false)
}
var hasScheme = true

0 comments on commit 46495c3

Please sign in to comment.
You can’t perform that action at this time.