feat(voyage): sync browser-side anchor-parser regex with Node-side allowlist
Step 16 of v4.3 playground plan. Mirror lib/parsers/anchor-parser.mjs
ANCHOR_LINE_RE + ATTR_RE + ID_RE constants verbatim into voyage-playground.html
inline-script (file COLON COLON scheme compat — no ES-module). parseAnchor(line)
validates id matches ANN-NNNN, target non-empty, line positive integer,
snippet ≤80c, intent in {fix,change,question,block}.
Trace: SC6, research/02 Sec T4, plan-critic blocker B4 + scope-guardian DEP-3.
Cross-file regex sync verified by static-grep test.
This commit is contained in:
parent
946eb7ab0f
commit
3973be2a90
2 changed files with 54 additions and 0 deletions
|
|
@ -200,3 +200,23 @@ test('voyage-playground.html declares popstate handler (v4.3 Step 15 back/forwar
|
|||
const text = readFileSync(HTML, 'utf-8');
|
||||
assert.match(text, /'popstate'/, 'popstate listener required for browser back/forward');
|
||||
});
|
||||
|
||||
test('voyage-playground.html declares VOYAGE_ANCHOR_RE constant (v4.3 Step 16 anchor allowlist)', () => {
|
||||
const text = readFileSync(HTML, 'utf-8');
|
||||
assert.match(text, /VOYAGE_ANCHOR_RE\s*=\s*\/\^/, 'VOYAGE_ANCHOR_RE regex constant required');
|
||||
assert.match(text, /VOYAGE_ANCHOR_ATTR_RE\s*=\s*\//, 'VOYAGE_ANCHOR_ATTR_RE constant required');
|
||||
assert.match(text, /VOYAGE_ANCHOR_ID_RE\s*=\s*\/\^ANN-/, 'VOYAGE_ANCHOR_ID_RE constant required');
|
||||
});
|
||||
|
||||
test('voyage-playground.html anchor regex matches Node-side allowlist (v4.3 Step 16 cross-file sync)', () => {
|
||||
const html = readFileSync(HTML, 'utf-8');
|
||||
const node = readFileSync(join(ROOT, 'lib', 'parsers', 'anchor-parser.mjs'), 'utf-8');
|
||||
const htmlMatch = html.match(/voyage:anchor[^/]+/)?.[0];
|
||||
const nodeMatch = node.match(/voyage:anchor[^/]+/)?.[0];
|
||||
assert.equal(htmlMatch, nodeMatch, 'first voyage:anchor token in HTML must mirror Node-side parser exactly');
|
||||
});
|
||||
|
||||
test('voyage-playground.html declares parseAnchor validator (v4.3 Step 16)', () => {
|
||||
const text = readFileSync(HTML, 'utf-8');
|
||||
assert.match(text, /function\s+parseAnchor\s*\(\s*line\s*\)/, 'parseAnchor(line) function required');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue