Skip to content

Commit 724d6d0

Browse files
committed
Fix formatting
1 parent 59f995e commit 724d6d0

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/main/java/org/nibor/autolink/internal/WwwScanner.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,57 +14,58 @@ public class WwwScanner implements Scanner {
1414
@Override
1515
public LinkSpan scan(final CharSequence input, int triggerIndex, int rewindIndex) {
1616
final int afterDot = triggerIndex + 4;
17-
if (afterDot >= input.length() || !isWWW(input, triggerIndex)) {
17+
if (afterDot >= input.length() || !isWww(input, triggerIndex)) {
1818
return null;
1919
}
2020

2121
final int first = findFirst(input, triggerIndex, rewindIndex);
2222
if (first == -1) {
2323
return null;
2424
}
25-
25+
2626
int last = findLast(input, afterDot);
2727
if (last == -1) {
2828
return null;
2929
}
3030

3131
return new LinkSpanImpl(LinkType.WWW, first, last + 1);
3232
}
33-
33+
3434
private static int findFirst(final CharSequence input, final int beginIndex, final int rewindIndex) {
3535
if (beginIndex == rewindIndex) {
3636
return beginIndex;
3737
}
38-
38+
3939
// Is the character before www. allowed?
4040
if (isAllowed(input.charAt(beginIndex - 1))) {
4141
return beginIndex;
4242
}
43-
43+
4444
return -1;
4545
}
46-
46+
4747
private static int findLast(final CharSequence input, final int beginIndex) {
4848
final int last = Scanners.findUrlEnd(input, beginIndex);
49-
49+
5050
// Make sure there is at least one dot after the first dot,
5151
// so www.something is not allowed, but www.something.co.uk is
5252
int pointer = last;
5353
while (--pointer > beginIndex) {
54-
if (input.charAt(pointer) == '.' && pointer > beginIndex) return last;
54+
if (input.charAt(pointer) == '.' && pointer > beginIndex) {
55+
return last;
56+
}
5557
}
56-
58+
5759
return -1;
5860
}
59-
61+
6062
private static boolean isAllowed(char c) {
6163
return c != '.' && !Scanners.isAlnum(c);
6264
}
63-
64-
private static boolean isWWW(final CharSequence input, final int triggerIndex) {
65-
return
66-
(input.charAt(triggerIndex + 1) == 'w')
67-
&& (input.charAt(triggerIndex + 2) == 'w')
68-
&& input.charAt(triggerIndex + 3) == '.';
65+
66+
private static boolean isWww(final CharSequence input, final int triggerIndex) {
67+
return input.charAt(triggerIndex + 1) == 'w'
68+
&& input.charAt(triggerIndex + 2) == 'w'
69+
&& input.charAt(triggerIndex + 3) == '.';
6970
}
7071
}

0 commit comments

Comments
 (0)