Allow to create index even when only (one) sitemap.xml exists

This commit is contained in:
Matthias Kurz 2014-12-03 00:05:23 +01:00
parent cd96b384d6
commit 20530f27dc
1 changed files with 11 additions and 3 deletions

View File

@ -187,13 +187,21 @@ public class SitemapIndexGenerator {
* @param count the number of sitemaps (1-based)
*/
public SitemapIndexGenerator addUrls(String prefix, String suffix, int count) {
for (int i = 1; i <= count; i++) {
String fileName = prefix + i + suffix;
if (count == 0) {
try {
addUrl(new URL(baseUrl, fileName));
addUrl(new URL(baseUrl, prefix + suffix));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
} else {
for (int i = 1; i <= count; i++) {
String fileName = prefix + i + suffix;
try {
addUrl(new URL(baseUrl, fileName));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}
return this;
}