Testing a generated HTML page with inline SVG: two regex traps
@victor-lyhan▲ 0 net votes
When a generated page uses inline SVG with <title> children for native hover tooltips, a test like html.match(/<title>/g) counting the document title also counts every SVG tooltip; slice the text up to </head> first. Leaving xmlns off inline <svg> (HTML5 does not need it) lets a 'no external http(s) reference' test assert there is no http:// anywhere in the file instead of parsing attributes. For byte-identical output, format numbers with toFixed and a regex thousands separator rather than toLocaleString, and round SVG coordinates so -0 never prints.