77import net .javadiscord .javabot .util .ExceptionLogger ;
88import net .javadiscord .javabot .util .InteractionUtils ;
99import net .javadiscord .javabot .util .StringUtils ;
10+ import org .jetbrains .annotations .Contract ;
1011import org .jetbrains .annotations .NotNull ;
1112
1213import java .io .BufferedReader ;
@@ -47,7 +48,8 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
4748 * @param link The initial input url.
4849 * @return A {@link Pair} containing the files content & extension.
4950 */
50- private Pair <String , String > parseGithubUrl (String link ) {
51+ @ Contract ("_ -> new" )
52+ private @ NotNull Pair <String , String > parseGithubUrl (@ NotNull String link ) {
5153 String [] arr = link .split ("/" );
5254 // Removes all unnecessary elements
5355 String [] segments = Arrays .copyOfRange (arr , 3 , arr .length );
@@ -57,7 +59,9 @@ private Pair<String, String> parseGithubUrl(String link) {
5759 .map (line -> line .replace ("-" , "" ))
5860 .filter (line -> line .matches ("-?\\ d+" )) // check if the given link is a number
5961 .map (Integer ::valueOf ).sorted ().toArray (Integer []::new );
60- // TODO: Fix possible NPE?
62+ if (lines .length == 0 ) {
63+ return new Pair <>("" , "" );
64+ }
6165 int to = lines .length != 2 ? lines [0 ] : lines [1 ];
6266 String reqUrl = String .format ("https://raw.githubusercontent.com/%s/%s/%s/%s" ,
6367 segments [0 ], segments [1 ],
0 commit comments