Skip to content

Commit

Permalink
Merge pull request #4149 from OSC/bp-external-urls
Browse files Browse the repository at this point in the history
allow redirect to other host in apps#show (#4140)
  • Loading branch information
johrstrom authored Feb 13, 2025
2 parents 4728d6e + abdd621 commit f5d9cd1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion apps/dashboard/app/apps/ood_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def links
OodAppLink.new(
title: title,
description: manifest.description,
url: (type == :sys && owner == :sys) ? app_path(name, nil, nil) : app_path(name, type, owner),
url: possibly_external_url,
icon_uri: icon_uri,
caption: caption,
new_tab: open_in_new_window?,
Expand All @@ -155,6 +155,20 @@ def links
end
end

# if the URL of the app is external, it's not a real app, just a hack to
# make an external link. In this case, we don't want the href to be
# 'app_path' (i.e., /pun/sys/dashboard/apps/show/<appname>), but instead
# be the actual external URL. This avoids an external host error in Rails,
# but also provides the user to know the _actual_ URL before clicking it.
def possibly_external_url
parsed_url = Addressable::URI.parse(url)
if parsed_url.relative?
(type == :sys && owner == :sys) ? app_path(name, nil, nil) : app_path(name, type, owner)
else
url
end
end

def links_without_validation
# hack - but at least this hack is in a method next to the method it is
# coupled with and this prevents control coupling from the outside by doing
Expand Down

0 comments on commit f5d9cd1

Please sign in to comment.