summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2021-01-21 16:49:19 -0600
committerMark Felder <feld@feld.me>2021-01-21 16:49:19 -0600
commit80ccdb56f623be21b3ec5b78fc55cee57bee1d2b (patch)
treec6fbf1b52c22a26f9ea0ac227102754c83f40913
parentd8860eaee46c9bc0a079e90dfb008c54923d7330 (diff)
Make tag urls absolute
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex2
-rw-r--r--test/pleroma/web/mastodon_api/views/status_view_test.exs8
3 files changed, 6 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1dfeae01..2727d1f2c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -54,6 +54,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Streaming API: Posts and notifications are not dropped, when CLI task is executing.
- Creating incorrect IPv4 address-style HTTP links when encountering certain numbers.
- Reblog API Endpoint: Do not set visibility parameter to public by default and let CommonAPI to infer it from status, so a user can reblog their private status without explicitly setting reblog visibility to private.
+- Tag URLs in statuses are now absolute
<details>
<summary>API Changes</summary>
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index cd1a85088..2cd6732fe 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -491,7 +491,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
def build_tags(object_tags) when is_list(object_tags) do
object_tags
|> Enum.filter(&is_binary/1)
- |> Enum.map(&%{name: &1, url: "/tag/#{URI.encode(&1)}"})
+ |> Enum.map(&%{name: &1, url: "#{Pleroma.Web.base_url()}/tag/#{URI.encode(&1)}"})
end
def build_tags(_), do: []
diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs
index 21a01658e..ed59cf285 100644
--- a/test/pleroma/web/mastodon_api/views/status_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs
@@ -263,7 +263,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
tags: [
%{
name: "#{object_data["tag"]}",
- url: "/tag/#{object_data["tag"]}"
+ url: "http://localhost:4001/tag/#{object_data["tag"]}"
}
],
application: %{
@@ -585,9 +585,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
]
assert StatusView.build_tags(object_tags) == [
- %{name: "fediverse", url: "/tag/fediverse"},
- %{name: "mastodon", url: "/tag/mastodon"},
- %{name: "nextcloud", url: "/tag/nextcloud"}
+ %{name: "fediverse", url: "http://localhost:4001/tag/fediverse"},
+ %{name: "mastodon", url: "http://localhost:4001/tag/mastodon"},
+ %{name: "nextcloud", url: "http://localhost:4001/tag/nextcloud"}
]
end
end