Skip to content

Commit

Permalink
Merge pull request #103 from bAmpT/patch-2
Browse files Browse the repository at this point in the history
Remove the 3 glyphs limit for the Custom Type
  • Loading branch information
polqf authored Aug 25, 2016
2 parents 162f8f8 + c590f41 commit a353f91
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ActiveLabel.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ActiveLabel'
s.version = '0.6.0'
s.version = '0.6.1'

s.author = { 'Optonaut' => '[email protected]' }
s.homepage = 'https://github.com/optonaut/ActiveLabel.swift'
Expand Down
7 changes: 5 additions & 2 deletions ActiveLabel/ActiveType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,23 @@ struct ActiveBuilder {
switch type {
case .Mention, .Hashtag:
return createElementsIgnoringFirstCharacter(from: text, for: type, range: range, filterPredicate: filterPredicate)
case .URL, .Custom:
case .URL:
return createElements(from: text, for: type, range: range, filterPredicate: filterPredicate)
case .Custom:
return createElements(from: text, for: type, range: range, minLength: 1, filterPredicate: filterPredicate)
}
}

private static func createElements(from text: String,
for type: ActiveType,
range: NSRange,
minLength: Int = 2,
filterPredicate: ActiveFilterPredicate?) -> [ElementTuple] {
let matches = RegexParser.getElements(from: text, with: type.pattern, range: range)
let nsstring = text as NSString
var elements: [ElementTuple] = []

for match in matches where match.range.length > 2 {
for match in matches where match.range.length > minLength {
let word = nsstring.substringWithRange(match.range)
.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
if filterPredicate?(word) ?? true {
Expand Down

0 comments on commit a353f91

Please sign in to comment.