landing-family-security.test.mjs
41 lines 1.5 KB
Raw
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6 docs: record AIP-b SD-21 land (KN #308) Human 10 days ago
1 import { describe, it } from 'node:test';
2 import assert from 'node:assert';
3 import { readFileSync } from 'node:fs';
4 import { fileURLToPath } from 'node:url';
5 import { dirname, join } from 'node:path';
6
7 const root = join(dirname(fileURLToPath(import.meta.url)), '..');
8 const indexHtml = readFileSync(join(root, 'web', 'index.html'), 'utf8');
9
10 describe('landing family links (security)', () => {
11 it('opens family outbound links in a new tab with noopener noreferrer', () => {
12 const familyHrefs = [
13 'https://ourware.org',
14 'https://scool.ing',
15 'https://the-brain.space',
16 'https://github.com/aaronrene/overseer-kit',
17 'https://www.facebook.com/profile.php?id=61593821631787',
18 'https://www.linkedin.com/company/143378951',
19 'https://www.youtube.com/channel/UC85lDAayTYjkqPFOyDaORWA',
20 'https://x.com/ourware',
21 ];
22 for (const href of familyHrefs) {
23 const re = new RegExp(
24 `href="${href.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}"([^>]*)>`,
25 'g'
26 );
27 const matches = [...indexHtml.matchAll(re)];
28 assert.ok(matches.length > 0, `missing ${href}`);
29 for (const m of matches) {
30 const attrs = m[1];
31 assert.match(attrs, /target="_blank"/);
32 assert.match(attrs, /rel="[^"]*noopener[^"]*noreferrer[^"]*"/);
33 }
34 }
35 });
36
37 it('does not introduce javascript: or data: family hrefs', () => {
38 assert.equal(/href="javascript:/i.test(indexHtml), false);
39 assert.equal(/href="data:/i.test(indexHtml), false);
40 });
41 });
File History 1 commit
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6 docs: record AIP-b SD-21 land (KN #308) Human 10 days ago