FIX: Follow the canonical URL when importing a remote topic. (#14489)

FinalDestination now supports the `follow_canonical` option, which will perform an initial GET request, parse the canonical link if present, and perform a HEAD request to it.

We use this mode during embeds to avoid treating URLs with different query parameters as different topics.
This commit is contained in:
Roman Rizzi
2021-10-01 12:48:21 -03:00
committed by GitHub
parent 0359adc0b8
commit 4c2d5158c5
4 changed files with 122 additions and 53 deletions

View File

@ -113,7 +113,8 @@ class TopicEmbed < ActiveRecord::Base
fd = FinalDestination.new(
url,
validate_uri: true,
max_redirects: 5
max_redirects: 5,
follow_canonical: true,
)
url = fd.resolve