Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Dec 12, 2018
1 parent b083537 commit 8e94168
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import android.text.TextUtils;

import com.kunfei.bookshelf.utils.NetworkUtil;
import com.kunfei.bookshelf.help.FormatWebText;
import com.kunfei.bookshelf.utils.StringUtils;

import org.jsoup.nodes.Element;
import org.jsoup.nodes.TextNode;
Expand Down Expand Up @@ -409,7 +409,7 @@ class SourceRule {
String replacement = "";

SourceRule(String ruleStr) {
if (ruleStr.toUpperCase().startsWith("@CSS:")) {
if (StringUtils.startWithIgnoreCase(ruleStr, "@CSS:")) {
isCss = true;
elementsRule = ruleStr.substring(5);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ class SourceRule {
String js;

SourceRule(String ruleStr) {
if (_isJSON && !ruleStr.startsWith("@JSon:"))
if (_isJSON && !StringUtils.startWithIgnoreCase(ruleStr, "@JSON:"))
throw new AssertionError("Content analyze");
String str[] = ruleStr.split("@js:");
if (str[0].startsWith("@XPath:")) {
if (StringUtils.startWithIgnoreCase(str[0], "@XPath:")) {
mode = Mode.XPath;
rule = str[0].substring(7);
} else if (str[0].startsWith("@JSon:")) {
} else if (StringUtils.startWithIgnoreCase(str[0], "@JSon:")) {
mode = Mode.JSon;
rule = str[0].substring(6);
} else {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/kunfei/bookshelf/utils/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,10 @@ public static boolean isJSONType(String str) {
return result;
}

public static boolean startWithIgnoreCase(String src, String obj) {
if (obj.length() > src.length()) {
return false;
}
return src.substring(0, obj.length()).equalsIgnoreCase(obj);
}
}

0 comments on commit 8e94168

Please sign in to comment.