Skip to content

Commit

Permalink
#10233 exclude url if the uri value is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Oswaldo Gallango committed May 2, 2017
1 parent 10a403b commit 4d124c4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dotCMS/src/main/java/com/dotcms/xmlsitemap/XMLSitemapJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.dotcms.contenttype.model.type.ContentType;
import com.dotcms.contenttype.transform.contenttype.StructureTransformer;
import com.dotcms.repackage.org.apache.commons.lang.StringUtils;
import com.dotmarketing.beans.Host;
import com.dotmarketing.beans.Identifier;
import com.dotmarketing.beans.Inode;
Expand Down Expand Up @@ -305,21 +306,22 @@ public void generateSitemapPerHost() throws DotDataException, DotSecurityExcepti
uri = page.getURI() + "?id=" + contenlet.getInode();
}
}
String urlRelacementText = getUrlPatternReplacementText( host, stVelocityVarName);
String urlReplacementText = getUrlPatternReplacementText( host, stVelocityVarName);

uri = uri.replaceAll(urlRelacementText, "");
uri = uri.replaceAll(urlReplacementText, "");

Logger.debug(this,
"Performing URL replacement - urlRelacementText ["
+ urlRelacementText
+ urlReplacementText
+ "], uri [" + uri + "]");

stringbuf = "<url><loc>"
if(StringUtils.isNotEmpty(uri)){
stringbuf = "<url><loc>"
+ XMLUtils.xmlEscape("http://"
+ host.getHostname() + uri)
+ "</loc><lastmod>"
+ modifiedDateStringValue
+ "</lastmod><changefreq>daily</changefreq></url>\n";
}
} else {
stringbuf = "<url><loc>"
+ XMLUtils.xmlEscape("http://"
Expand Down

0 comments on commit 4d124c4

Please sign in to comment.