@@ -23,7 +23,7 @@ struct ActiveBuilder {
2323 }
2424 }
2525
26- static func createURLElements( from text: String , range: NSRange , maxChar : Int ? ) -> ( [ ElementTuple ] , String ) {
26+ static func createURLElements( from text: String , range: NSRange , maximumLenght : Int ? ) -> ( [ ElementTuple ] , String ) {
2727 let type = ActiveType . URL
2828 var text = text
2929 let matches = RegexParser . getElements ( from: text, with: type. pattern, range: range)
@@ -34,14 +34,14 @@ struct ActiveBuilder {
3434 let word = nsstring. substringWithRange ( match. range)
3535 . stringByTrimmingCharactersInSet ( NSCharacterSet . whitespaceAndNewlineCharacterSet ( ) )
3636
37- guard let maxChar = maxChar where word. characters. count > maxChar else {
38- let newRange = ( text as NSString ) . rangeOfString ( word)
37+ guard let maxLenght = maximumLenght where word. characters. count > maxLenght else {
38+ let range = maximumLenght == nil ? match . range : ( text as NSString ) . rangeOfString ( word)
3939 let element = ActiveElement . create ( with: type, text: word)
40- elements. append ( ( newRange , element, type) )
40+ elements. append ( ( range , element, type) )
4141 continue
4242 }
4343
44- let trimmedWord = word. trim ( to: maxChar )
44+ let trimmedWord = word. trim ( to: maxLenght )
4545 text = text. stringByReplacingOccurrencesOfString ( word, withString: trimmedWord)
4646
4747 let newRange = ( text as NSString ) . rangeOfString ( trimmedWord)
0 commit comments