Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
implementation 'org.dom4j:dom4j:2.1.3'
implementation 'org.apache.commons:commons-text:1.10.0'

implementation platform('run.halo.tools.platform:plugin:2.5.0-SNAPSHOT')
implementation platform('run.halo.tools.platform:plugin:2.9.0-SNAPSHOT')
compileOnly 'run.halo.app:api'

testImplementation 'run.halo.app:api'
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/run/halo/feed/FeedServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import run.halo.app.infra.SystemSetting;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Objects;

@Service
Expand Down Expand Up @@ -135,9 +137,9 @@ private Mono<FeedContext> getFeedContext(ServerRequest request) {
Assert.notNull(basicPluginSetting.getDescriptionType(),
"descriptionType cannot be null");

var externalUrl = externalUrlSupplier.get();
if (!externalUrl.isAbsolute()) {
externalUrl = request.exchange().getRequest().getURI().resolve(externalUrl);
var externalUrl = externalUrlSupplier.getRaw();
if (externalUrl == null) {
externalUrl = externalUrlSupplier.getURL(request.exchange().getRequest());
}
// Build feed context
return new FeedContext(basicPluginSetting, systemBasicSetting, externalUrl);
Expand All @@ -155,13 +157,17 @@ private Mono<ServerResponse> postListResultToXmlServerResponse(
if (permalink != null) {
var permalinkUri = URI.create(permalink);
if (!permalinkUri.isAbsolute()) {
permalinkUri = feedContext.externalUrl.resolve(permalinkUri);
try {
permalinkUri = feedContext.externalUrl.toURI().resolve(permalinkUri);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
permalink = permalinkUri.toString();
}
var itemBuilder = RSS2.Item.builder()
.title(post.getSpec().getTitle())
.link(permalink)
.link(feedContext.externalUrl.toString() + permalink)
.pubDate(post.getSpec().getPublishTime())
.guid(post.getStatusOrDefault().getPermalink());

Expand Down Expand Up @@ -207,6 +213,6 @@ private RSS2 buildBaseRss(FeedContext feedContext) {
}

record FeedContext(BasicSetting basicPluginSetting, SystemSetting.Basic systemBasicSetting,
URI externalUrl) {
URL externalUrl) {
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
spec:
enabled: true
version: 1.1.1
requires: ">=2.4.0"
requires: ">=2.7.0"
author:
name: Halo OSS Team
website: https://github.com/halo-dev
Expand Down