fulldecent/html-validate-nice-checkers

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

Geschlossen

#28 geöffnet am 24.06.2026

 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (1 Fork)github user discovery
help wanted

Repository-Metriken

Stars
 (2 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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

Contributor Guide