use URI not URL in content extraction and CLAUDE.md style guide
This commit is contained in:
parent
4f589f2449
commit
e0fb466c36
2 changed files with 13 additions and 12 deletions
|
|
@ -615,3 +615,4 @@ openai==2.3.0
|
|||
## Style
|
||||
|
||||
- **Never use "AI" — always say "machine learning."** We grow machine learning, not "AI." This term is forbidden in all permacomputer discourse, marketing, & documentation.
|
||||
- **Use "URI" not "URL."** URI is the correct general term. URL is a subset. Default to URI in code, comments, and documentation.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// Content extraction and processing functionality
|
||||
|
||||
// URL translation rules — map dynamic page patterns to raw/plain text equivalents.
|
||||
// Each rule: { pattern: RegExp matching the full URL, translate: (match) => rawURL }
|
||||
const URL_TRANSLATIONS = [
|
||||
// URI translation rules — map dynamic page patterns to raw/plain text equivalents.
|
||||
// Each rule: { pattern: RegExp matching the full URI, translate: (match) => rawURI }
|
||||
const URI_TRANSLATIONS = [
|
||||
{
|
||||
// GitLab CI job pages → raw log output
|
||||
// e.g. https://git.example.com/group/project/-/jobs/12345 → .../jobs/12345/raw
|
||||
|
|
@ -11,16 +11,16 @@ const URL_TRANSLATIONS = [
|
|||
},
|
||||
];
|
||||
|
||||
// Try to fetch raw content via URL translation (same-origin, cookies included).
|
||||
// Try to fetch raw content via URI translation (same-origin, cookies included).
|
||||
// Returns { raw: string } on success, { matched: true } if pattern matched but
|
||||
// fetch failed (signals a dynamic page worth waiting for), or null if no match.
|
||||
async function fetchTranslatedContent(url) {
|
||||
for (const rule of URL_TRANSLATIONS) {
|
||||
const match = url.match(rule.pattern);
|
||||
async function fetchTranslatedContent(uri) {
|
||||
for (const rule of URI_TRANSLATIONS) {
|
||||
const match = uri.match(rule.pattern);
|
||||
if (match) {
|
||||
try {
|
||||
const rawUrl = rule.translate(match);
|
||||
const response = await fetch(rawUrl, { credentials: "same-origin" });
|
||||
const rawUri = rule.translate(match);
|
||||
const response = await fetch(rawUri, { credentials: "same-origin" });
|
||||
if (response.ok) {
|
||||
const text = await response.text();
|
||||
if (text && text.length > 0) {
|
||||
|
|
@ -28,7 +28,7 @@ async function fetchTranslatedContent(url) {
|
|||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("URL translation fetch failed, falling back to DOM:", e);
|
||||
console.warn("URI translation fetch failed, falling back to DOM:", e);
|
||||
}
|
||||
// Pattern matched but fetch failed — caller should wait for DOM to settle
|
||||
return { matched: true };
|
||||
|
|
@ -108,7 +108,7 @@ function extractDOMContent() {
|
|||
}
|
||||
|
||||
// Extract text content along with links and metadata from the webpage.
|
||||
// Tries URL translation first (raw/plain text for known dynamic pages),
|
||||
// Tries URI translation first (raw/plain text for known dynamic pages),
|
||||
// falls back to DOM extraction.
|
||||
export async function extractWebpageContent() {
|
||||
const result = await fetchTranslatedContent(window.location.href);
|
||||
|
|
@ -120,7 +120,7 @@ export async function extractWebpageContent() {
|
|||
if (title) {
|
||||
content += `**Page Title**: ${title}\n\n`;
|
||||
}
|
||||
content += `**Source URL**: ${window.location.href}\n\n`;
|
||||
content += `**Source URI**: ${window.location.href}\n\n`;
|
||||
content += result.raw;
|
||||
return content.trim();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue