Skip to content

Commit

Permalink
Fatal on digit or special char.
Browse files Browse the repository at this point in the history
There was a problem when only special char or digit
was on input. Then a empty string Was created.
Added checking about isEmpty
  • Loading branch information
Damian Panasiuk committed Feb 26, 2021
1 parent d148b4a commit 4504b96
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Binary file modified library/SjpApi.jar
Binary file not shown.
14 changes: 11 additions & 3 deletions src/CurlHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ public class CurlHelper {
private static CurlValidator validator = new CurlValidator();
private static CurlWrapper wrapper = new CurlWrapper();

private static String readCurlFromSJP(String word) throws IOException {
return reader.getCurlOutput("https://sjp.pl/"+word);
}

public static String getOutputFromCurl(String word) throws IOException {

if (word.isEmpty() == true){
word = "empty";
}

String outputFromCurl = readCurlFromSJP(word);

if (validator.isCurlValidate(outputFromCurl) == true) {
Expand All @@ -21,6 +23,12 @@ public static String getOutputFromCurl(String word) throws IOException {
return "";
}

private static String readCurlFromSJP(String word) throws IOException {
return reader.getCurlOutput("https://sjp.pl/"+word);
}






Expand Down
19 changes: 18 additions & 1 deletion src/StringUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.sjp.sjpapi;

import android.text.InputFilter;
import android.text.Spanned;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
Expand Down Expand Up @@ -106,7 +109,21 @@ public static boolean hasSpecyficHTMLTags(String text){
}

public static final String deleteSpecialChar(String text){
text = text.replaceAll("[^\\p{Alpha}]+","");
text = text.replaceAll("[^\\p{IsAlphabetic}\\p{IsDigit}]", "");
return text;
}

public static final String deleteEmoji(String text) {

for (int index = 0; index < text.length(); index++) {

int type = Character.getType(text.charAt(index));

if (type == Character.SURROGATE) {
text.substring(index);
}
}
return text;
}

}

0 comments on commit 4504b96

Please sign in to comment.