Skip to content

Commit 7943130

Browse files
committed
Throw IllegalArgumentException when url is null in LinkHandlerFactory
1 parent 39de55d commit 7943130

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public abstract class LinkHandlerFactory {
3434
public abstract String getUrl(String id) throws ParsingException;
3535
public abstract boolean onAcceptUrl(final String url) throws ParsingException;
3636

37-
public String getUrl(String id, String baseUrl) throws ParsingException{
37+
public String getUrl(String id, String baseUrl) throws ParsingException {
3838
return getUrl(id);
3939
}
4040

@@ -43,13 +43,14 @@ public String getUrl(String id, String baseUrl) throws ParsingException{
4343
///////////////////////////////////
4444

4545
public LinkHandler fromUrl(String url) throws ParsingException {
46+
if (url == null) throw new IllegalArgumentException("url can not be null");
4647
final String baseUrl = Utils.getBaseUrl(url);
4748
return fromUrl(url, baseUrl);
4849
}
4950

5051
public LinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
51-
if(url == null) throw new IllegalArgumentException("url can not be null");
52-
if(!acceptUrl(url)) {
52+
if (url == null) throw new IllegalArgumentException("url can not be null");
53+
if (!acceptUrl(url)) {
5354
throw new ParsingException("Malformed unacceptable url: " + url);
5455
}
5556

@@ -58,13 +59,13 @@ public LinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
5859
}
5960

6061
public LinkHandler fromId(String id) throws ParsingException {
61-
if(id == null) throw new IllegalArgumentException("id can not be null");
62+
if (id == null) throw new IllegalArgumentException("id can not be null");
6263
final String url = getUrl(id);
6364
return new LinkHandler(url, url, id);
6465
}
6566

6667
public LinkHandler fromId(String id, String baseUrl) throws ParsingException {
67-
if(id == null) throw new IllegalArgumentException("id can not be null");
68+
if (id == null) throw new IllegalArgumentException("id can not be null");
6869
final String url = getUrl(id, baseUrl);
6970
return new LinkHandler(url, url, id);
7071
}

0 commit comments

Comments
 (0)