我在这个扩展中发现了两个 bug。我不确定这些 bug 是新出现的还是早已存在,但我只是最近才遇到它们。
- 即使域名已在设置中被豁免,相对链接仍然会在新窗口/标签页中打开:
https://discuss.flarum.org/d/39094-relative-urls-open-in-a-new-tab
- Safari 控制台中有一个错误:
https://discuss.flarum.org/d/39048-flarum-1x-console-error
第一个问题的解决方法可以在这里找到。请注意,许多组件都会尝试修改链接,所以如果您想完全摒弃这些行为,可以在 extend.php 中做类似这样的操作:
// Override link behavior: open all links in the current tab with no rel attributes.
// The v17development/flarum-seo extension injects target="_blank" and rel="noopener"
// on all external links. This also affects relative URLs (/d/...) which get treated
// as external. Uses Flarum's Extend\Link API to override.
// Note: space is used for rel because empty string is falsy in the Link extender's if-check.
(new Extend\Link)
->setTarget(fn($uri, $siteUrl, $attrs) => '_self')
->setRel(fn($uri, $siteUrl, $attrs) => ' ')
这本质上与 flarum-ext-dofollow 中的解决方法相同。
我不知道第二个问题的修复方法,但看起来并不严重,只是在这里报告一下,希望能在下一个版本中修复。