Replace dirty words checker with allowed-links rule - #163
Conversation
Co-authored-by: fulldecent <382183+fulldecent@users.noreply.github.com>
…complete Co-authored-by: fulldecent <382183+fulldecent@users.noreply.github.com>
|
@copilot do not remove our dirty file path checker |
Co-authored-by: fulldecent <382183+fulldecent@users.noreply.github.com>
Restored the dirty file paths checker as requested. The files |
|
@copilot fix the sitemap thing that is not working in your build (and may have been broken before you started) and also fix the new prettier lint error you introduced |
Co-authored-by: fulldecent <382183+fulldecent@users.noreply.github.com>
Fixed both issues:
The sitemap generation now works properly and the workflow will set the appropriate URL ( Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Changes Made
Replaced dirty words checker with allowed-links rule:
allowed-linksrule in.htmlvalidate.mjswith the specified exclusion patterns:allowExternal.exclude:"\\\\?utm_source=chatgpt.com"and".htm[l]?$"allowRelative.exclude:".htm[l]?$"allowAbsolute.exclude:".htm[l]?$"Removed obsolete dirty words files:
test/dirty-words.jsonandtest/dirty-words-checker.mjsKept dirty file paths checker:
test/dirty-file-paths.jsonandtest/dirty-file-paths-checker.mjspackage.jsontest script to include dirty-file-paths-checkerFixed code quality issues:
.htmlvalidate.mjsandtest/fixtures/required-results.jsonscripts/generate-sitemap.mjsto support configurable site URL viaSITE_URLenvironment variableUpdated test expectations:
test/fixtures/required-results.jsonto include newallowed-linksviolationsFunctionality Preserved
The new implementation maintains all the previous validation behavior:
✅ UTM parameter detection: Links with
?utm_source=chatgpt.comare flagged as violations✅ HTML extension blocking: Both
.htmland.htmfile extensions are blocked for relative and external links✅ File path validation: Dirty file paths checker continues to validate file types (images, fonts, videos, etc.)
✅ Test coverage: All existing test cases pass with updated expectations
✅ Sitemap generation: Now works with configurable site URLs and proper GitHub Pages integration
Improvements
SITE_URLenvironment variable for custom deploymentsTrade-off
As noted in the issue, we lose the ability to test for double-escaped HTML entities (like
&amp;) in link validation, but this was deemed acceptable for the cleaner implementation using html-validate's native rules.The migration results in a net reduction of ~150 lines of custom code while maintaining equivalent functionality through html-validate's robust link validation system and preserving the file path validation capabilities.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.