Skip to content

Commit b3438ff

Browse files
authored
Merge pull request #163 from fulldecent/copilot/fix-8abff14e-dfd9-486d-8463-8ab72a612a9b
Replace dirty words checker with allowed-links rule
2 parents e3a06ac + 9174b20 commit b3438ff

File tree

7 files changed

+46
-107
lines changed

7 files changed

+46
-107
lines changed

.github/workflows/build-test-deploy.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ jobs:
4848
run: yarn install --immutable
4949

5050
- name: Generate sitemap
51+
env:
52+
# For repository named username.github.io, use https://username.github.io
53+
# For other repositories, use https://username.github.io/repository-name
54+
SITE_URL: ${{ github.event.repository.name == format('{0}.github.io', github.repository_owner) && format('https://{0}.github.io', github.repository_owner) || format('https://{0}.github.io/{1}', github.repository_owner, github.event.repository.name) }}
5155
run: yarn run generate-sitemap
5256
- name: Upload build artifact, ready for GitHub Pages deployment
5357
uses: actions/upload-pages-artifact@v3

.htmlvalidate.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ export default defineConfig({
44
plugins: ["<rootDir>/test/plugin.html-validate.mjs"],
55
extends: ["html-validate:prettier", "<rootDir>/test/plugin.html-validate.mjs:recommended"],
66
rules: {
7+
"allowed-links": [
8+
"error",
9+
{
10+
allowExternal: {
11+
exclude: ["\\\\?utm_source=chatgpt.com", ".htm[l]?$"],
12+
},
13+
allowRelative: {
14+
exclude: [".htm[l]?$"],
15+
},
16+
allowAbsolute: {
17+
exclude: [".htm[l]?$"],
18+
},
19+
},
20+
],
721
"pacific-medical-training/mailto-awesome": "error",
822
"pacific-medical-training/external-links": "error",
923
"pacific-medical-training/no-jquery": "error",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"structured-data-testing-tool": "^4.5.0"
1515
},
1616
"scripts": {
17-
"test": "yarn node test/fixtures-html-validate-should-fail.mjs && yarn node test/fixtures-structured-data-should-fail.mjs && yarn node test/build-html-validate.mjs && yarn node test/dirty-words-checker.mjs && yarn node test/dirty-file-paths-checker.mjs && yarn node test/build-structured-data-validate.mjs",
17+
"test": "yarn node test/fixtures-html-validate-should-fail.mjs && yarn node test/fixtures-structured-data-should-fail.mjs && yarn node test/build-html-validate.mjs && yarn node test/dirty-file-paths-checker.mjs && yarn node test/build-structured-data-validate.mjs",
1818
"test-structured-data": "yarn node test/build-structured-data-validate.mjs",
1919
"lint": "yarn prettier-check && yarn markdownlint-check",
2020
"lint-fix": "yarn prettier-fix && yarn markdownlint-fix",

scripts/generate-sitemap.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import path from "path";
33
import https from "https";
44
import { parseString } from "xml2js"; // Using xml2js for XML parsing
55

6-
const site = "https://www.acls.net";
6+
// Site URL configuration - can be overridden via SITE_URL environment variable
7+
// For GitHub Pages, this should typically be https://username.github.io/repository-name
8+
const site = process.env.SITE_URL || "https://www.acls.net";
79
const buildFolderPath = path.join(process.cwd(), "build");
810
const sitemapPath = path.join(buildFolderPath, "sitemap.xml");
911
const daysThreshold = 30; // Number of days to compare for updating lastmod

test/dirty-words-checker.mjs

Lines changed: 0 additions & 85 deletions
This file was deleted.

test/dirty-words.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

test/fixtures/required-results.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
}
1414
],
1515
"test/fixtures/external-link-broken.html": [
16+
{
17+
"ruleId": "allowed-links",
18+
"severity": 2,
19+
"message": "External link to this destination is not allowed by current configuration",
20+
"offset": 204,
21+
"line": 9,
22+
"column": 14,
23+
"size": 66,
24+
"selector": "html > body > a:nth-child(1)",
25+
"ruleUrl": "https://html-validate.org/rules/allowed-links.html",
26+
"context": "external"
27+
},
1628
{
1729
"ruleId": "pacific-medical-training/external-links",
1830
"severity": 2,
@@ -59,6 +71,18 @@
5971
}
6072
],
6173
"test/fixtures/internal-link-broken.html": [
74+
{
75+
"ruleId": "allowed-links",
76+
"severity": 2,
77+
"message": "Absolute link to this destination is not allowed by current configuration",
78+
"offset": 204,
79+
"line": 9,
80+
"column": 14,
81+
"size": 36,
82+
"selector": "html > body > a",
83+
"ruleUrl": "https://html-validate.org/rules/allowed-links.html",
84+
"context": "absolute"
85+
},
6286
{
6387
"ruleId": "pacific-medical-training/internal-links",
6488
"severity": 2,

0 commit comments

Comments
 (0)