如果我理解正确的话,Discourse 使用 GitHub - markdown-it/linkify-it: Links recognition library with full unicode support 来提供一个漂亮的带标题的链接。例如,上面的链接提供了一个漂亮的标题 GitHub - markdown-it/linkify-it: Links recognition library with full unicode support。
然而,我遇到了以下问题:要访问发布的一些链接,您必须在其他工具(例如 Jira、Google 等)中进行身份验证。所以发生的情况是,所有链接(对于某些转换后的 URL,还有代码块)只会显示 Login to support 或 Meet Google Drive – One place for all your files[...],这并不太好。
是否已经有现有的功能或组件/插件可以预先测试 URL,并在存在重定向的情况下,不为 URL 提供标题?
2 个赞
sam
(Sam Saffron)
2022 年5 月 16 日 02:27
2
是的,我们这里的通用解决方案是使用 blocked onebox domains 站点设置。
将所有内部“需要登录”的 URL 添加到该列表中。
我想知道 @nat /@codinghorror 是否应该在此处添加一个“锤子”设置。
block onebox on redirect - 该设置可以在发生重定向时完全阻止任何 onebox。它提供了一个非常简单的杠杆来无条件地控制跨多个域的此行为。
3 个赞
感谢您提供有关内部链接的提示。
我们非常希望能够提供更通用的功能,例如“阻止重定向的一框式显示”,因为我们无法预知用户可能发布的完整列表。
这似乎对链接化的链接不起作用,这些链接并未更新为“一框式显示”,而只是变成了标题(例如,我们的内部链接 https://support.sqills.com/browse/SCQI-934 变成了 Log in - Sqills Jira,但基本 URL 只会给出 https://support.sqills.com 作为链接标题)。
2 个赞
sam
(Sam Saffron)
2022 年5 月 17 日 00:20
4
这里肯定有一个令人困惑的错误,我们应该解决它。
我刚刚阻止了 support.sqills.com,并确认它对 <https://support.sqills.com/browse/SCQI-934?1> https://support.sqills.com/browse/SCQI-934?1 正常工作,但遗憾的是 https://support.sqills.com/browse/SCQI-934 被服务器端缓存了 24 小时,并且重建 HTML 并不能清除缓存。
我们将在本周解决这个小麻烦,以便减少这方面的支持。阻止重定向作为一种选项听起来对我来说很棒,我们也许可以挤出时间来做。也许 block onebox on cross domain redirect(阻止跨域重定向上的 onebox)更好,或者也许这有点太过了……不确定。
2 个赞
Osama
2022 年5 月 23 日 05:54
9
这已在以下位置修复:
committed 11:09AM - 20 May 22 UTC
Meta topic: https://meta.discourse.org/t/prevent-to-linkify-when-there-is-a-redi… rect/226964/4?u=osama.
现在,当帖子被重建时,在重建之前,帖子中所有链接的缓存条目都会被删除。
并且这里有一个用于添加 block_onebox_on_redirect 站点设置的 PR:
main ← feature/block-onebox-for-urls-that-redirect
opened 11:09AM - 20 May 22 UTC
Meta topic: https://meta.discourse.org/t/prevent-to-linkify-when-there-is-a-redi… rect/226964/2?u=osama.
This PR adds a new site setting `block_onebox_on_redirect` (default off) for blocking oneboxes (full and inline) of URLs that redirect. Note that an initial http → https redirect is still allowed if the redirect location is identical to the source (minus the scheme of course). For example, if a user includes a link to `http://example.com/page` and the link resolves to `https://example.com/page`, then the link will onebox (assuming it can be oneboxed) even if the setting is enabled. The reason for this is a user may type out a URL (i.e. the URL is short and memorizable) with http and since a lot of sites support TLS with http traffic automatically redirected to https, so we should still allow the URL to onebox.
当启用 block_onebox_on_redirect 时,Discourse 永远不会对重定向的 URL 进行 onebox。唯一的例外是如果一个 URL 是 http 并重定向到该 URL 的 https 版本。这样做是因为支持 TLS 的站点通常会将 http 流量重定向到 https,因此如果用户输入了带有 http 的链接并且站点重定向到 https,onebox 仍然应该工作。
2 个赞