Skip to content

Commit

Permalink
fix: incorrect sitemap link in robots.txt (#24)
Browse files Browse the repository at this point in the history
### What this PR does?
修复 robots.txt 中 sitemap 链接不正确的问题

Fixes #23

```release-note
修复 robots.txt 中 Sitemap 链接不正确的问题
```
  • Loading branch information
guqing authored Sep 25, 2023
1 parent 6dc91d6 commit 4ebd330
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/run/halo/sitemap/SitemapPluginConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.net.MalformedURLException;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.http.CacheControl;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -60,7 +61,9 @@ RouterFunction<ServerResponse> robotsTextFunction() {
.bodyValue(defaultRule);
}
var uri = externalUrlSupplier.getURL(request.exchange().getRequest());
var sitemapURL = "Sitemap: " + uri + "sitemap.xml";
var sitemapURL = "Sitemap: "
+ StringUtils.appendIfMissing(uri.toString(), "/")
+ "sitemap.xml";
return ServerResponse.ok()
.cacheControl(CacheControl.noCache())
.contentType(MediaType.TEXT_PLAIN)
Expand Down

0 comments on commit 4ebd330

Please sign in to comment.