Skip to content

Commit

Permalink
better pattern constant names
Browse files Browse the repository at this point in the history
  • Loading branch information
ikarsokolov committed Feb 28, 2016
1 parent 79d4be0 commit b2ee751
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/takes/facets/fork/MediaType.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
final class MediaType implements Comparable<MediaType> {

/**
* Media type priority clean pattern.
* Pattern matching non-digit symbols.
*/
private static final Pattern CLEANER = Pattern.compile("[^0-9\\.]");
private static final Pattern NON_DIGITS = Pattern.compile("[^0-9\\.]");

/**
* Priority.
Expand Down Expand Up @@ -118,7 +118,8 @@ private static Double priority(final String text) {
final String[] parts = MediaType.split(text);
final Double priority;
if (parts.length > 1) {
final String num = CLEANER.matcher(parts[1]).replaceAll("");
final String num =
MediaType.NON_DIGITS.matcher(parts[1]).replaceAll("");
if (num.isEmpty()) {
priority = 0.0d;
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/takes/misc/Href.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
public final class Href implements CharSequence {

/**
* Trailer slash pattern.
* Pattern matching trailing slash.
*/
private static final Pattern TRAILER = Pattern.compile("/$");
private static final Pattern TRAILING_SLASH = Pattern.compile("/$");

/**
* URI (without the query part).
Expand Down Expand Up @@ -202,7 +202,8 @@ public Href path(final Object suffix) {
return new Href(
URI.create(
new StringBuilder(
TRAILER.matcher(this.uri.toString()).replaceAll("")
Href.TRAILING_SLASH.matcher(this.uri.toString())
.replaceAll("")
)
.append('/')
.append(Href.encode(suffix.toString())).toString()
Expand Down

0 comments on commit b2ee751

Please sign in to comment.