/src/main/java/com/ingenieux/nullweblog/util/URIUtil.java
https://bitbucket.org/aldrinleal/nullweblog · Java · 28 lines · 20 code · 8 blank · 0 comment · 1 complexity · 72b011ee1d742965df96f9708f3934fc MD5 · raw file
- package com.ingenieux.nullweblog.util;
-
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
-
- public class URIUtil {
- private static final URIUtil INSTANCE = new URIUtil();
-
- public static final URIUtil getInstance() {
- return INSTANCE;
- }
-
- private static final Pattern PATTERN_ROOT = Pattern
- .compile("^(http://[^/]+).*$");
-
- public StringBuilder getRequestBase(String requestPath) {
- Matcher matcher = PATTERN_ROOT.matcher(requestPath);
-
- if (!matcher.find())
- return new StringBuilder("");
-
- return new StringBuilder(matcher.group(1));
- }
-
- public StringBuilder getRequestBase(StringBuffer buffer) {
- return getRequestBase(buffer.toString());
- }
- }