Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions ietf/static/js/document_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ document.addEventListener("DOMContentLoaded", function (event) {
defpane.show();
document.activeElement.blur();

// keep RFC links within the datatracker
const rfclink = /^https?:\/\/[^\/\.]*.(?:rfc-editor|ietf).org\/.*\/((?:rfc|std|bcp)\d+)$/;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps should limit the subdomains that are treated as RFC links here. A link to https://notes.ietf.org/.../bcp7890 isn't an RFC link. It's also not a great example as it's not likely to appear at all, but the point is real RFC links are at a more constrained set of hosts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't confident that I could enumerate the locations. Is it just www.ietf.org and datatracker.ietf.org and www.rfc-editor.org? The deployment architecture of this stuff (and its history) are a bit opaque to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look, but imo it'd be better to start off conservatively

const docbase = document.location.origin + "/doc/html/";
[...document.querySelectorAll(".references dd a:not([href='']:last-of-type)"),
...document.querySelectorAll("#identifiers a.eref")]
.forEach(ref => {
const docnum = ref.href.match(rfclink);
if (!doccnum) { return; }
if (ref.textContent === ref.href) {
ref.textContent = docbase + docnum[1];
}
ref.href = docbase + docnum[1];
});

if (localStorage.getItem("reflinks") != "refsection") {
// make links to references go directly to the referenced doc
document.querySelectorAll("a[href^='#'].xref")
Expand All @@ -103,16 +117,6 @@ document.addEventListener("DOMContentLoaded", function (event) {
const url = loc.querySelector(
"a:not([href='']:last-of-type)");
if (url) {
const rfc = url.href.match(/(rfc\d+)$/i);
if (rfc) {
// keep RFC links within the datatracker
const base = ref.href.match(
/^(.*\/)rfc\d+.*$/i);
if (base) {
ref.href = base[1] + rfc[1];
return;
}
}
ref.href = url.href;
}
});
Expand Down
Loading