-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop #27
Develop #27
Changes from all commits
30edf40
db5499b
8eccc02
c5ca35a
4ad50e8
f5d175b
e3962db
12dbb18
91983c7
b3aa876
034f39c
8867bcf
dff9dd2
ef23830
6038532
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
swift: | ||
enabled: true | ||
config_file: .swift-format |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"fileScopedDeclarationPrivacy" : { | ||
"accessLevel" : "private" | ||
}, | ||
"indentation" : { | ||
"spaces" : 4 | ||
}, | ||
"indentConditionalCompilationBlocks" : false, | ||
"indentSwitchCaseLabels" : false, | ||
"lineBreakAroundMultilineExpressionChainComponents" : false, | ||
"lineBreakBeforeControlFlowKeywords" : false, | ||
"lineBreakBeforeEachArgument" : true, | ||
"lineBreakBeforeEachGenericRequirement" : false, | ||
"lineLength" : 200, | ||
"maximumBlankLines" : 1, | ||
"multiElementCollectionTrailingCommas" : true, | ||
"noAssignmentInExpressions" : { | ||
"allowedFunctions" : [ | ||
"XCTAssertNoThrow" | ||
] | ||
}, | ||
"prioritizeKeepingFunctionOutputTogether" : false, | ||
"respectsExistingLineBreaks" : true, | ||
"rules" : { | ||
"AllPublicDeclarationsHaveDocumentation" : false, | ||
"AlwaysUseLiteralForEmptyCollectionInit" : false, | ||
"AlwaysUseLowerCamelCase" : true, | ||
"AmbiguousTrailingClosureOverload" : true, | ||
"BeginDocumentationCommentWithOneLineSummary" : false, | ||
"DoNotUseSemicolons" : true, | ||
"DontRepeatTypeInStaticProperties" : true, | ||
"FileScopedDeclarationPrivacy" : true, | ||
"FullyIndirectEnum" : true, | ||
"GroupNumericLiterals" : true, | ||
"IdentifiersMustBeASCII" : true, | ||
"NeverForceUnwrap" : false, | ||
"NeverUseForceTry" : false, | ||
"NeverUseImplicitlyUnwrappedOptionals" : false, | ||
"NoAccessLevelOnExtensionDeclaration" : false, | ||
"NoAssignmentInExpressions" : true, | ||
"NoBlockComments" : false, | ||
"NoCasesWithOnlyFallthrough" : true, | ||
"NoEmptyTrailingClosureParentheses" : true, | ||
"NoLabelsInCasePatterns" : true, | ||
"NoLeadingUnderscores" : false, | ||
"NoParensAroundConditions" : true, | ||
"NoPlaygroundLiterals" : true, | ||
"NoVoidReturnOnFunctionSignature" : true, | ||
"OmitExplicitReturns" : false, | ||
"OneCasePerLine" : true, | ||
"OneVariableDeclarationPerLine" : true, | ||
"OnlyOneTrailingClosureArgument" : true, | ||
"OrderedImports" : true, | ||
"ReplaceForEachWithForLoop" : true, | ||
"ReturnVoidInsteadOfEmptyTuple" : true, | ||
"TypeNamesShouldBeCapitalized" : true, | ||
"UseEarlyExits" : false, | ||
"UseLetInEveryBoundCaseVariable" : false, | ||
"UseShorthandTypeNames" : true, | ||
"UseSingleLinePropertyGetter" : true, | ||
"UseSynthesizedInitializer" : false, | ||
"UseTripleSlashForDocumentationComments" : true, | ||
"UseWhereClausesInForLoops" : false, | ||
"ValidateDocumentationComments" : false | ||
}, | ||
"spacesAroundRangeFormationOperators" : false, | ||
"tabWidth" : 4, | ||
"version" : 1 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
// | ||
// Created by kojirof on 2018/11/16. | ||
// Copyright © 2018 Gumob. All rights reserved. | ||
// Created by Kojiro futamura on 2018/11/16. | ||
// | ||
|
||
import Foundation | ||
|
||
#if SWIFT_PACKAGE | ||
import Punycode | ||
#endif | ||
|
@@ -25,9 +25,7 @@ internal class PSLParser { | |
} | ||
|
||
internal func parse(data: Data?) throws -> PSLDataSet { | ||
guard let data: Data = data, | ||
let str: String = String(data: data, encoding: .utf8), | ||
str.count > 0 else { | ||
guard let data: Data = data, let str: String = String(data: data, encoding: .utf8), str.count > 0 else { | ||
throw TLDExtractError.pslParseError(message: nil) | ||
} | ||
|
||
|
@@ -49,9 +47,9 @@ internal class PSLParser { | |
#endif | ||
} | ||
return PSLDataSet( | ||
exceptions: exceptions, | ||
wildcards: wildcards, | ||
normals: normals | ||
exceptions: exceptions, | ||
wildcards: wildcards, | ||
normals: normals | ||
) | ||
} | ||
} | ||
|
@@ -68,8 +66,7 @@ internal class TLDParser { | |
let hostComponents: [String] = host.lowercased().components(separatedBy: ".") | ||
/// Search exceptions first, then search wildcards if not match | ||
let matchClosure: (PSLData) -> Bool = { $0.matches(hostComponents: hostComponents) } | ||
let pslData: PSLData? = self.pslDataSet.exceptions.first(where: matchClosure) ?? | ||
self.pslDataSet.wildcards.first(where: matchClosure) | ||
let pslData: PSLData? = self.pslDataSet.exceptions.first(where: matchClosure) ?? self.pslDataSet.wildcards.first(where: matchClosure) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line Length Violation: Line should be 120 characters or less: currently 141 characters (line_length) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line Length Violation: Line should be 120 characters or less: currently 141 characters (line_length) |
||
return pslData?.parse(hostComponents: hostComponents) | ||
} | ||
|
||
|
@@ -100,9 +97,11 @@ internal class TLDParser { | |
let subDomainRange: Range<Int> = (hostComponents.startIndex)..<(max(secondDomainRange.lowerBound, hostComponents.startIndex)) | ||
let subDomain: String? = subDomainRange.endIndex >= 1 ? hostComponents[subDomainRange].joined(separator: ".") : nil | ||
|
||
return TLDResult(rootDomain: rootDomain, | ||
topLevelDomain: topLevelDomain, | ||
secondLevelDomain: secondDomain, | ||
subDomain: subDomain) | ||
return TLDResult( | ||
rootDomain: rootDomain, | ||
topLevelDomain: topLevelDomain, | ||
secondLevelDomain: secondDomain, | ||
subDomain: subDomain | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 120 characters or less: currently 141 characters (line_length)