optimize url matching

This commit is contained in:
Haowei Wen 2022-05-02 22:30:37 +08:00
parent cfbfc7f5ba
commit 45ca1e0f84

View file

@ -68,6 +68,10 @@ public class URLProcessor {
* @return the transformed URL, or empty if it doesn't need to be transformed
*/
public Optional<String> transformURL(String inputUrl) {
if (!inputUrl.startsWith("http")) {
// fast path
return Optional.empty();
}
Matcher matcher = URL_REGEX.matcher(inputUrl);
if (!matcher.find()) {
return Optional.empty();