Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: FavIcon/Utils.swift

Issue 29664569: Favicon: Issue 6245 - SwiftLinted project files (Closed)
Patch Set: Favicon: Issue 6245 - SwiftLinted project files Created Jan. 12, 2018, 4:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « FavIcon/URLRequestOperation.swift ('k') | FavIconTests/FavIconsTests.swift » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: FavIcon/Utils.swift
diff --git a/FavIcon/Utils.swift b/FavIcon/Utils.swift
index 5f738d3db092c50f32e51ad0057bb18ce426f179..7e543847cdad70b860d9c46294937cad99e957de 100644
--- a/FavIcon/Utils.swift
+++ b/FavIcon/Utils.swift
@@ -21,14 +21,14 @@ extension String {
func parseAsHTTPContentTypeHeader() -> (mimeType: String, encoding: String.Encoding) {
let headerComponents =
components(separatedBy: ";")
- .map { $0.trimmingCharacters(in: .whitespaces) }
+ .map { $0.trimmingCharacters(in: .whitespaces) }
if headerComponents.count > 1 {
let parameters =
headerComponents[1..<headerComponents.count]
- .filter { $0.contains("=") }
- .map { $0.components(separatedBy: "=") }
- .toDictionary { ($0[0], $0[1]) }
+ .filter { $0.contains("=") }
+ .map { $0.components(separatedBy: "=") }
+ .toDictionary { ($0[0], $0[1]) }
// Default according to RFC is ISO-8859-1, but probably nothing obeys that, so default
// to UTF-8 instead.
@@ -48,22 +48,38 @@ extension String {
//swiftlint:disable cyclomatic_complexity
func parseAsStringEncoding() -> String.Encoding? {
switch lowercased() {
- case "iso-8859-1", "latin1": return String.Encoding.isoLatin1
- case "iso-8859-2", "latin2": return String.Encoding.isoLatin2
- case "iso-2022-jp": return String.Encoding.iso2022JP
- case "shift_jis": return String.Encoding.shiftJIS
- case "us-ascii": return String.Encoding.ascii
- case "utf-8": return String.Encoding.utf8
- case "utf-16": return String.Encoding.utf16
- case "utf-32": return String.Encoding.utf32
- case "utf-32be": return String.Encoding.utf32BigEndian
- case "utf-32le": return String.Encoding.utf32LittleEndian
- case "windows-1250": return String.Encoding.windowsCP1250
- case "windows-1251": return String.Encoding.windowsCP1251
- case "windows-1252": return String.Encoding.windowsCP1252
- case "windows-1253": return String.Encoding.windowsCP1253
- case "windows-1254": return String.Encoding.windowsCP1254
- case "x-mac-roman": return String.Encoding.macOSRoman
+ case "iso-8859-1", "latin1":
+ return String.Encoding.isoLatin1
+ case "iso-8859-2", "latin2":
+ return String.Encoding.isoLatin2
+ case "iso-2022-jp":
+ return String.Encoding.iso2022JP
+ case "shift_jis":
+ return String.Encoding.shiftJIS
+ case "us-ascii":
+ return String.Encoding.ascii
+ case "utf-8":
+ return String.Encoding.utf8
+ case "utf-16":
+ return String.Encoding.utf16
+ case "utf-32":
+ return String.Encoding.utf32
+ case "utf-32be":
+ return String.Encoding.utf32BigEndian
+ case "utf-32le":
+ return String.Encoding.utf32LittleEndian
+ case "windows-1250":
+ return String.Encoding.windowsCP1250
+ case "windows-1251":
+ return String.Encoding.windowsCP1251
+ case "windows-1252":
+ return String.Encoding.windowsCP1252
+ case "windows-1253":
+ return String.Encoding.windowsCP1253
+ case "windows-1254":
+ return String.Encoding.windowsCP1254
+ case "x-mac-roman":
+ return String.Encoding.macOSRoman
default:
return nil
}
« no previous file with comments | « FavIcon/URLRequestOperation.swift ('k') | FavIconTests/FavIconsTests.swift » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld