aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/www/controllers/Site.java8
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java17
2 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/com/juick/www/controllers/Site.java b/src/main/java/com/juick/www/controllers/Site.java
index f4f8f744..06513fcc 100644
--- a/src/main/java/com/juick/www/controllers/Site.java
+++ b/src/main/java/com/juick/www/controllers/Site.java
@@ -217,8 +217,12 @@ public class Site {
}
return "views/index";
}
-
- @GetMapping(path = "/{uname}/", headers = "Connection!=Upgrade")
+ @GetMapping(value = "/{uname}/", produces = { MediaType.APPLICATION_JSON_VALUE, Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE,
+ Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE })
+ public RedirectView blogRedirect(@PathVariable String uname) {
+ return new RedirectView("/u/" + uname);
+ }
+ @GetMapping(value = "/{uname}/", produces = { MediaType.TEXT_HTML_VALUE, MediaType.ALL_VALUE })
protected String doGetBlog(@Parameter(hidden = true) User visitor, @RequestParam(required = false, name = "show") String paramShow,
@RequestParam(required = false, name = "tag") String paramTagStr,
@RequestParam(required = false, name = "search") String paramSearch,
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 5d149277..bb70e875 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -2528,6 +2528,23 @@ public class ServerTests {
}
@Test
+ public void ldRequestToBlogShouldRedirect() throws Exception {
+ var htmlUri = String.format("/ugnich/");
+ var ldUri = String.format("/u/ugnich");
+ mockMvc.perform(get(htmlUri).accept(Context.LD_JSON_MEDIA_TYPE)).andExpect(status().is3xxRedirection())
+ .andExpect(redirectedUrl(ldUri));
+ mockMvc.perform(get(htmlUri).accept(MediaType.APPLICATION_JSON)).andExpect(status().is3xxRedirection())
+ .andExpect(redirectedUrl(ldUri));
+ var mastodonAcceptHeader = "application/activity+json, application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\", text/html;q=0.1";
+ mockMvc.perform(get(htmlUri).accept(mastodonAcceptHeader)).andExpect(status().is3xxRedirection())
+ .andExpect(redirectedUrl(ldUri));
+ var webclientHeader = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
+ mockMvc.perform(get(htmlUri).accept(webclientHeader)).andExpect(status().isOk());
+ mockMvc.perform(get(htmlUri)).andExpect(status().isOk());
+ mockMvc.perform(get(ldUri)).andExpect(status().isOk());
+ }
+
+ @Test
@Transactional
public void unsignedOverlowTest() throws Exception {
var result = commandsManager.processCommand(ugnich, "test", emptyUri);