diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 2ebe97c4b..6d1d84511 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -44,6 +44,21 @@ jobs: run: npm i - name: Run linter run: npm run lint + - name: Detect changed documentation files + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: shell + filters: | + docs: + - '*.md' + - '.github/**.md' + - name: Check documentation links + if: steps.changes.outputs.docs == 'true' + run: | + npx markdown-link-check --retry \ + ${{ steps.changes.outputs.docs_files }} + continue-on-error: ${{ github.ref == 'refs/heads/develop' }} - name: Verify file permissions run: | CHECK_DIRS="icons/ _data/" diff --git a/README.md b/README.md index 5ee9eb50d..47594c422 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ echo file_get_contents('path/to/package/icons/simpleicons.svg'); | [Drawio library](https://github.com/mondeja/simple-icons-drawio) Drawio | [@mondeja](https://github.com/mondeja) | | [Drupal module](https://www.drupal.org/project/simple_icons) Drupal | [Phil Wolstenholme](https://www.drupal.org/u/phil-wolstenholme) | | [Figma plugin](https://www.figma.com/community/plugin/1149614463603005908/Simple-Icons) Figma | [@LitoMore](https://github.com/LitoMore) | -| [Flutter package](https://pub.dev/packages/simple_icons) Flutter | [@jlnrrg](https://jlnrrg.github.io/) | +| [Flutter package](https://pub.dev/packages/simple_icons) Flutter | [@jlnrrg](https://github.com/jlnrrg) | | [Framer component](https://github.com/LitoMore/simple-icons-framer) Framer | [@LitoMore](https://github.com/LitoMore) | | [Hexo plugin](https://github.com/nidbCN/hexo-simpleIcons) Hexo | [@nidbCN](https://github.com/nidbCN/) | | [Home Assistant plugin](https://github.com/vigonotion/hass-simpleicons) Home Assistant | [@vigonotion](https://github.com/vigonotion/) | diff --git a/package.json b/package.json index e348992f7..c7f77da07 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "husky": "8.0.3", "is-ci": "3.0.1", "jsonschema": "1.4.1", + "markdown-link-check": "3.11.2", "mocha": "10.2.0", "named-html-entities-json": "1.0.0", "npm-run-all": "4.1.5", diff --git a/tests/docs.test.js b/tests/docs.test.js index c88b460e0..b5c56e70b 100644 --- a/tests/docs.test.js +++ b/tests/docs.test.js @@ -1,19 +1,6 @@ -import fs from 'node:fs/promises'; -import path from 'node:path'; import { test } from 'mocha'; import { strict as assert } from 'node:assert'; -import { - getThirdPartyExtensions, - getDirnameFromImportMeta, - URL_REGEX, -} from '../sdk.mjs'; - -const __dirname = getDirnameFromImportMeta(import.meta.url); -const root = path.dirname(__dirname); -const getLinksRegex = new RegExp( - URL_REGEX.source.replace('^https', 'https?'), - 'gm', -); +import { getThirdPartyExtensions } from '../sdk.mjs'; test('README third party extensions must be alphabetically sorted', async () => { const thirdPartyExtensions = await getThirdPartyExtensions(); @@ -30,25 +17,3 @@ test('README third party extensions must be alphabetically sorted', async () => 'Wrong alphabetical order of third party extensions in README.', ); }); - -test('Only allow HTTPS links in documentation pages', async () => { - const ignoreHttpLinks = ['http://www.w3.org/2000/svg']; - - const docsFiles = (await fs.readdir(root)).filter((fname) => - fname.endsWith('.md'), - ); - - for (const docsFile of docsFiles) { - const docsFilePath = path.join(root, docsFile); - const docsFileContent = await fs.readFile(docsFilePath, 'utf8'); - - for (const match of docsFileContent.matchAll(getLinksRegex)) { - const link = match[0]; - assert.ok( - ignoreHttpLinks.includes(link) || link.startsWith('https://'), - `Link '${link}' in '${docsFile}' (at index ${match.index})` + - ` must use the HTTPS protocol.`, - ); - } - } -});