Слияние кода завершено, страница обновится автоматически
позволяет корректно расположить ресурсы?
public static String getRelPath(String siblings, String resourceId) {
String relResourceId = null;
if (resourceId != null && resourceId.length() != 0) {
char cs = resourceId.charAt(0);
if (cs != '\\' && cs != '/') {
int i = siblings.length() - 1;
boolean find;
for (find = false; i > 0; --i) {
char c = siblings.charAt(i);
if (c == '\\' || c == '/') {
find = true;
break;
}
}
if (find) {
String parent = siblings.substring(0, i + 1);
**relResourceId = parent.concat(resourceId);**
} else {
relResourceId = resourceId;
}
} else {
relResourceId = resourceId;
}
if (isOutsideOfRoot(relResourceId)) {
throw new RuntimeException("Недопустимый доступ к внешним файлам или шаблонам");
} else {
return relResourceId;
}
} else {
throw new RuntimeException("Идентификатор ресурса пустой, неверные входные данные");
}
}
relResourceId = parent.concat(resourceId);
Не удаляет разделители перед соединением.
Например: include("http://xxx.html"){}
, разделитель "http:"
также должен быть удален.
Есть ли более подходящий способ записи include
?