diff --git a/CHANGELOG.md b/CHANGELOG.md index ee123e3..bdea4b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All notable product changes will be recorded in this file. `textContent` fallback. - Added page title provenance to Markdown output. - Kept page titles inside a Markdown-inert untrusted-content fence. +- Canonicalized supported source URLs without query parameters or fragments. - Added structural blockquote boundaries for untrusted body and comment previews. - Added regression checks for hidden content, Markdown structure, background diff --git a/README.md b/README.md index 11d1a3f..43ffe13 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ a complete GitHub conversation exporter. - recognizes GitHub Issue pages - recognizes GitHub Pull Request conversation pages -- extracts the visible title, source URL, body preview, and visible comment snippets +- extracts the visible title, canonical source URL without query/fragment data, body preview, and visible comment snippets - creates a Markdown preview with the title, explicit limitations, and a review-before-sharing warning - keeps the title inside a Markdown-inert fenced block and body/comment previews inside an explicit untrusted-content blockquote boundary - copies the Markdown to the clipboard diff --git a/docs/01_requirements.md b/docs/01_requirements.md index f3660c3..9502069 100644 --- a/docs/01_requirements.md +++ b/docs/01_requirements.md @@ -23,7 +23,7 @@ Pull Request support is limited to the Conversation page. - repository owner and name - Issue or Pull Request number - page type -- source URL +- canonical source URL without query parameters or fragments - export timestamp - exporter name diff --git a/docs/03_status.md b/docs/03_status.md index 11473ee..cb920e0 100644 --- a/docs/03_status.md +++ b/docs/03_status.md @@ -11,7 +11,8 @@ Maintainer-controlled public OSS preview. - Chrome Manifest V3 popup - GitHub Issue and Pull Request Conversation URL classification - self-contained visible-page metadata injection -- visible title, source URL, body preview, and visible comment snippets +- visible title, canonical source URL without query/fragment data, body + preview, and visible comment snippets - rendered-visibility checks that reject hidden, inert, transparent, or non-rendered body/comment elements - explicit body selectors that do not promote the first comment into a diff --git a/src/extractor/pageMetadata.js b/src/extractor/pageMetadata.js index f9fd01d..29b908b 100644 --- a/src/extractor/pageMetadata.js +++ b/src/extractor/pageMetadata.js @@ -52,6 +52,9 @@ export function extractVisiblePageMetadata() { const heading = normalizeText(document.querySelector("h1")?.innerText); const path = document.location.pathname; const pageKind = classifyPageKind(path); + const canonicalUrl = pageKind + ? `https://github.com${path.replace(/\/$/, "")}` + : ""; let visibleContentPreview = ""; let visibleContentStatus = "not_applicable"; @@ -108,7 +111,7 @@ export function extractVisiblePageMetadata() { return { title, heading, - url: document.location.href, + url: canonicalUrl, visibleContentPreview, visibleContentStatus, visibleComments, diff --git a/test/pageMetadata.test.mjs b/test/pageMetadata.test.mjs index 6d2a638..0c281fa 100644 --- a/test/pageMetadata.test.mjs +++ b/test/pageMetadata.test.mjs @@ -63,7 +63,7 @@ test("runs as a self-contained injected function for an Issue page", () => { kind: "issue", title: "Example issue · GitHub", heading: "Example issue", - url: "https://github.com/octo-org/example/issues/123", + url: "https://github.com/octo-org/example/issues/123?notification_referrer_id=synthetic#issuecomment-synthetic", body: "Visible issue body", comments: ["First visible comment"] })); @@ -80,7 +80,7 @@ test("runs as a self-contained injected function for a Pull Request page", () => kind: "pull request", title: "Example pull request · GitHub", heading: "Example pull request", - url: "https://github.com/octo-org/example/pull/456", + url: "https://github.com/octo-org/example/pull/456/?synthetic=1#discussion_rsynthetic", body: "Visible pull request body", comments: ["Review conversation comment"] }));