Skip to content

Commit a8aab11

Browse files
committed
Fetch title from nightly in preference to main URL
(no less buggy than for existing sources per #360)
1 parent bed45aa commit a8aab11

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Diff for: specs.json

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"url": "https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis",
1111
"shortname": "rfc6265bis",
1212
"organization": "IETF",
13-
"title": "Cookies: HTTP State Management Mechanism",
1413
"groups": [
1514
{
1615
"name": "HTTP Working Group",

Diff for: src/fetch-info.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ async function fetchInfoFromSpecref(specs, options) {
255255

256256
async function fetchInfoFromSpecs(specs, options) {
257257
const info = await Promise.all(specs.map(async spec => {
258-
const dom = await JSDOM.fromURL(spec.url);
258+
const url = spec.nightly?.url || spec.url;
259+
const dom = await JSDOM.fromURL(url);
259260

260261
if (spec.url.startsWith("https://tc39.es/")) {
261262
// Title is either flagged with specific class or the second h1
@@ -264,7 +265,7 @@ async function fetchInfoFromSpecs(specs, options) {
264265
dom.window.document.querySelectorAll("h1")[1];
265266
if (h1ecma) {
266267
return {
267-
nightly: { url: spec.url },
268+
nightly: { url: url },
268269
title: h1ecma.textContent.replace(/\n/g, '').trim()
269270
};
270271
}
@@ -273,7 +274,7 @@ async function fetchInfoFromSpecs(specs, options) {
273274
const h1 = dom.window.document.querySelector("h1");
274275
if (h1) {
275276
return {
276-
nightly: { url: spec.url },
277+
nightly: { url: url },
277278
title: h1.textContent.replace(/\n/g, '').trim()
278279
};
279280
}
@@ -283,12 +284,12 @@ async function fetchInfoFromSpecs(specs, options) {
283284
const title = dom.window.document.querySelector("title");
284285
if (title) {
285286
return {
286-
nightly: { url: spec.url },
287+
nightly: { url: url },
287288
title: title.textContent.replace(/\n/g, '').trim()
288289
};
289290
}
290291

291-
throw `Could not find title in ${spec.url} for spec "${spec.shortname}"`;
292+
throw `Could not find title in ${url} for spec "${spec.shortname}"`;
292293
}));
293294

294295
const results = {};

0 commit comments

Comments
 (0)