FIX: Render links with subfolders properly in Discobot

Currently, some links aren’t properly built in Discobot when Discourse
is hosted in a subfolder. This is because we’re providing
`Discourse.base_url` to the Rails helpers which contains the base URL
*with* the prefix. But Rails helpers already handle this prefix so the
resulting link gets the prefix twice.

The fix is quite simple: use `Discourse.base_url_no_prefix` instead of
`Discourse.base_url`.
This commit is contained in:
Loïc Guitaut
2023-04-06 17:55:30 +02:00
committed by Loïc Guitaut
parent a5235f7d16
commit 430d6308a8
3 changed files with 21 additions and 12 deletions

View File

@ -638,7 +638,10 @@ module DiscourseNarrativeBot
end
def url_helpers(url, opts = {})
Rails.application.routes.url_helpers.public_send(url, opts.merge(host: Discourse.base_url))
Rails.application.routes.url_helpers.public_send(
url,
opts.merge(host: Discourse.base_url_no_prefix),
)
end
end
end