0.7.1: README links and images absolute (npmjs.com rendered relative paths as 404s); test keeps README free of relative links
This commit is contained in:
parent
ba8cfd2594
commit
d5ffc159c0
8 changed files with 39 additions and 29 deletions
|
|
@ -67,6 +67,11 @@ describe('links resolve', () => {
|
|||
test('README.md and docs/*.md', () => {
|
||||
expect([join(ROOT, 'README.md'), ...docs].flatMap(problems)).toEqual([]);
|
||||
});
|
||||
test('README.md has only absolute links and images (npm renders it on npmjs.com, where relative paths 404)', () => {
|
||||
const md = readFileSync(join(ROOT, 'README.md'), 'utf8');
|
||||
const rel = [...md.matchAll(/!?\]\((?!https?:|#|mailto:)([^)\s]+)\)|(?:src|href)="(?!https?:|#|mailto:)([^"]+)"/g)].map(m => m[1] ?? m[2]);
|
||||
expect(rel).toEqual([]);
|
||||
});
|
||||
test('site pages', () => {
|
||||
const pages = ['site/index.html', 'site/desktop/index.html'].map(p => join(ROOT, p)).filter(existsSync);
|
||||
expect(pages.flatMap(problems)).toEqual([]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue