FIX: Hide broken theme about/license URLs (#29930)

At the top of the theme show page we have a link
to the theme About and License, which are supposed
to be URLs. However some themes have left placeholder
text in these metadata fields, which leads to a wonky
experience.

Instead, we can just not serialize these fields if they
are not valid URLs, then they will not show as links
in the UI.
This commit is contained in:
Martin Brennan
2024-11-26 13:53:10 +10:00
committed by GitHub
parent 3a11e70b3d
commit e708c99e12
3 changed files with 48 additions and 3 deletions

View File

@@ -19,10 +19,14 @@ class RemoteThemeSerializer < ApplicationSerializer
:minimum_discourse_version,
:maximum_discourse_version
# wow, AMS has some pretty nutty logic where it tries to find the path here
# from action dispatch, tell it not to
# ActiveModelSerializer has some pretty nutty logic where it tries to find
# the path here from action dispatch, tell it not to
def about_url
object.about_url
object.about_url if UrlHelper.is_valid_url?(object.about_url)
end
def license_url
object.license_url if UrlHelper.is_valid_url?(object.license_url)
end
def include_github_diff_link?