private static String getSuffix(final WebResponse response) { // first try to take the one from the requested file final String url = response.getWebRequest().getUrl().toString(); final String fileName = StringUtils.substringAfterLast(StringUtils.substringBefore(url, "?"), "/"); // if there is a suffix with 2-4 letters, the take it final String suffix = StringUtils.substringAfterLast(fileName, "."); if (suffix.length() > 1 && suffix.length() < 5) { return suffix; } // use content type return MimeType.getFileExtension(response.getContentType()); }
private static String getSuffix(final WebResponse response) { // first try to take the one from the requested file final String url = response.getWebRequest().getUrl().toString(); final String fileName = StringUtils.substringAfterLast(StringUtils.substringBefore(url, "?"), "/"); // if there is a suffix with 2-4 letters, the take it final String suffix = StringUtils.substringAfterLast(fileName, "."); if (suffix.length() > 1 && suffix.length() < 5) { return suffix; } // use content type return MimeType.getFileExtension(response.getContentType()); }