fulldecent/html-validate-nice-checkers

bug: canonical-link false positive on root URLs with multi-character TLDs (.app, .io, .dev, etc.)

已關閉

#28 建立於 2026年6月24日

 (3 則留言) (0 個反應) (0 位負責人)TypeScript (1 個分叉)github user discovery
help wanted

倉庫指標

星標
 (2 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Bug report

The nice-checkers/canonical-link rule incorrectly flags root canonical URLs when the TLD is multi-character (.app, .io, .dev, .ai, etc.).

Root cause

The extension check runs against the full URL string:

if (/\.\w+$/.test(href)) {

https://webscore.app matches because .app satisfies \.\w+$, even though the pathname has no extension.

Suggested fix

Test only url.pathname instead:

const url = new URL(href)
if (/\.\w+$/.test(url.pathname)) {

https://webscore.app has pathname /, so it passes. https://example.com/page.html has pathname /page.html, so extensions are still caught correctly.

Relates to #26

貢獻者指南