Fixed the broken fix

This commit is contained in:
Kristian Knarvik 2018-02-01 13:56:57 +01:00
parent 9d18abf1ed
commit f0618d6338
2 changed files with 4 additions and 4 deletions

View File

@ -103,10 +103,10 @@ class Main {
* @return The wanted substring. * @return The wanted substring.
*/ */
private static String stringBetween(String string, String start, String end) { private static String stringBetween(String string, String start, String end) {
if (!string.contains(start)) { int startPos = string.indexOf(start) + start.length();
if (!string.contains(start) || string.indexOf(end, startPos) < startPos) {
return ""; return "";
} }
int startPos = string.indexOf(start) + start.length();
return string.substring(startPos, string.indexOf(end, startPos)); return string.substring(startPos, string.indexOf(end, startPos));
} }
} }

View File

@ -350,10 +350,10 @@ public class Server {
* @return The wanted substring. * @return The wanted substring.
*/ */
private static String stringBetween(String string, String start, String end) { private static String stringBetween(String string, String start, String end) {
if (!string.contains(start)) { int startPos = string.indexOf(start) + start.length();
if (!string.contains(start) || string.indexOf(end, startPos) < startPos) {
return ""; return "";
} }
int startPos = string.indexOf(start) + start.length();
return string.substring(startPos, string.indexOf(end, startPos)); return string.substring(startPos, string.indexOf(end, startPos));
} }