Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Check documentation link origin and escape live status text (part of #508)

Nguyen Xuan An1d0083f8ccc4
diff --git a/src/docs-live.js b/src/docs-live.js
index c5a1e153..e04dfe35 100644
--- a/src/docs-live.js
+++ b/src/docs-live.js
@@ -166,7 +166,12 @@ export function createLiveExample({ source, title, poster, file = 'main.js', asp
function setStatus(kind, text) {
status.dataset.kind = kind;
- status.innerHTML = text ? `${icon(kind === 'error' ? 'warning' : 'check')}<span>${text}</span>` : '';
+ status.replaceChildren();
+ if (!text) return;
+ status.insertAdjacentHTML('afterbegin', icon(kind === 'error' ? 'warning' : 'check'));
+ const label = document.createElement('span');
+ label.textContent = text;
+ status.append(label);
}
async function run() {
diff --git a/src/documentation.js b/src/documentation.js
index 7a9e5cd2..b94397fd 100644
--- a/src/documentation.js
+++ b/src/documentation.js
@@ -48,7 +48,7 @@ function inlineText(value) {
return escapeHtml(value)
.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (match, label, href) => {
- const external = /^https?:/.test(href) && !href.startsWith('https://67js.codepawl.com');
+ const external = /^https?:/.test(href) && new URL(href, 'https://67js.codepawl.com').origin !== 'https://67js.codepawl.com';
return `<a href="${href}"${external ? ' rel="noopener"' : ''}>${label}</a>`;
});
}