From 971f49a67e5b04b4f2d19fa5b7df806fee70b9f9 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 7 Jun 2024 22:32:58 -0700 Subject: [PATCH] Delete no longer needed Scanner+Extensions. --- .../Web/UTS46/Scanner+Extensions.swift | 54 ------------------- Web/Sources/Web/UTS46/String+Punycode.swift | 24 ++++----- 2 files changed, 12 insertions(+), 66 deletions(-) delete mode 100644 Web/Sources/Web/UTS46/Scanner+Extensions.swift diff --git a/Web/Sources/Web/UTS46/Scanner+Extensions.swift b/Web/Sources/Web/UTS46/Scanner+Extensions.swift deleted file mode 100644 index 0ffb0c425..000000000 --- a/Web/Sources/Web/UTS46/Scanner+Extensions.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// Scanner+Extensions.swift -// PunyCocoa Swift -// -// Created by Nate Weaver on 2020-04-20. -// - -import Foundation - -// Wrapper functions for < 10.15 compatibility -// TODO: Remove when support for < 10.15 is dropped. -extension Scanner { - - func shimScanUpToCharacters(from set: CharacterSet) -> String? { - if #available(macOS 10.15, iOS 13.0, *) { - return self.scanUpToCharacters(from: set) - } else { - var str: NSString? - self.scanUpToCharacters(from: set, into: &str) - return str as String? - } - } - - func shimScanCharacters(from set: CharacterSet) -> String? { - if #available(macOS 10.15, iOS 13.0, *) { - return self.scanCharacters(from: set) - } else { - var str: NSString? - self.scanCharacters(from: set, into: &str) - return str as String? - } - } - - func shimScanUpToString(_ substring: String) -> String? { - if #available(macOS 10.15, iOS 13.0, *) { - return self.scanUpToString(substring) - } else { - var str: NSString? - self.scanUpTo(substring, into: &str) - return str as String? - } - } - - func shimScanString(_ searchString: String) -> String? { - if #available(macOS 10.15, iOS 13.0, *) { - return self.scanString(searchString) - } else { - var str: NSString? - self.scanString(searchString, into: &str) - return str as String? - } - } - -} diff --git a/Web/Sources/Web/UTS46/String+Punycode.swift b/Web/Sources/Web/UTS46/String+Punycode.swift index 42a923b40..479b87a8e 100644 --- a/Web/Sources/Web/UTS46/String+Punycode.swift +++ b/Web/Sources/Web/UTS46/String+Punycode.swift @@ -23,7 +23,7 @@ public extension String { let dotAt = CharacterSet(charactersIn: ".@") while !s.isAtEnd { - if let input = s.shimScanUpToCharacters(from: dotAt) { + if let input = s.scanUpToCharacters(from: dotAt) { if !input.isValidLabel { return nil } if input.rangeOfCharacter(from: nonASCII) != nil { @@ -37,7 +37,7 @@ public extension String { } } - if let input = s.shimScanCharacters(from: dotAt) { + if let input = s.scanCharacters(from: dotAt) { result.append(input) } } @@ -55,7 +55,7 @@ public extension String { let dotAt = CharacterSet(charactersIn: ".@") while !s.isAtEnd { - if let input = s.shimScanUpToCharacters(from: dotAt) { + if let input = s.scanUpToCharacters(from: dotAt) { if input.lowercased().hasPrefix("xn--") { let start = input.index(input.startIndex, offsetBy: 4) guard let substr = input[start...].punycodeDecoded else { return nil } @@ -66,7 +66,7 @@ public extension String { } } - if let input = s.shimScanCharacters(from: dotAt) { + if let input = s.scanCharacters(from: dotAt) { result.append(input) } } @@ -388,29 +388,29 @@ private extension String { var password: String? var fragment: String? - if let hostOrScheme = s.shimScanUpToCharacters(from: colonSlash) { - let maybeDelim = s.shimScanCharacters(from: colonSlash) ?? "" + if let hostOrScheme = s.scanUpToCharacters(from: colonSlash) { + let maybeDelim = s.scanCharacters(from: colonSlash) ?? "" if maybeDelim.hasPrefix(":") { delim = maybeDelim scheme = hostOrScheme - host = s.shimScanUpToCharacters(from: slashQuestion) ?? "" + host = s.scanUpToCharacters(from: slashQuestion) ?? "" } else { path.append(hostOrScheme) path.append(maybeDelim) } - } else if let maybeDelim = s.shimScanString("//") { + } else if let maybeDelim = s.scanString("//") { delim = maybeDelim - if let maybeHost = s.shimScanUpToCharacters(from: slashQuestion) { + if let maybeHost = s.scanUpToCharacters(from: slashQuestion) { host = maybeHost } } - path.append(s.shimScanUpToString("#") ?? "") + path.append(s.scanUpToString("#") ?? "") - if s.shimScanString("#") != nil { - fragment = s.shimScanUpToCharacters(from: .newlines) ?? "" + if s.scanString("#") != nil { + fragment = s.scanUpToCharacters(from: .newlines) ?? "" } let usernamePasswordHostPort = host.components(separatedBy: "@")