(minor) EdgeUrl.parse() should deal with null

This commit is contained in:
Viktor Lofgren 2023-07-24 15:06:57 +02:00
parent bc330acfc9
commit 7470c170b1

View File

@ -5,6 +5,7 @@ import lombok.Getter;
import lombok.Setter;
import nu.marginalia.util.QueryParams;
import javax.annotation.Nullable;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
@ -33,8 +34,12 @@ public class EdgeUrl {
this(new URI(urlencodeFixer(url)));
}
public static Optional<EdgeUrl> parse(String url) {
public static Optional<EdgeUrl> parse(@Nullable String url) {
try {
if (null == url) {
return Optional.empty();
}
return Optional.of(new EdgeUrl(url));
} catch (URISyntaxException e) {
return Optional.empty();