Skip to content

Commit 5f9793f

Browse files
tidoustdontcallmedom
authored andcommitted
Improve short title logic for IETF specs
HTTP/1.1 spec titles were incorrectly shortened as "HTTP/1.1" (see #364). With this update, they get shortened as "HTTP/1.1 [module name]". This update also explicitly sets the short title of a couple of IETF specs in specs.json as they did not produce suitable short titles. Short titles could still be further improved and shortened in some cases, but they should at least be correct.
1 parent 13a9bc3 commit 5f9793f

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

Diff for: specs.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,15 @@
319319
}
320320
]
321321
},
322-
"https://www.rfc-editor.org/rfc/rfc4120",
322+
{
323+
"url": "https://www.rfc-editor.org/rfc/rfc4120",
324+
"shortTitle": "Kerberos"
325+
},
323326
"https://www.rfc-editor.org/rfc/rfc6265",
324-
"https://www.rfc-editor.org/rfc/rfc6266",
327+
{
328+
"url": "https://www.rfc-editor.org/rfc/rfc6266",
329+
"shortTitle": "Content-Disposition in HTTP"
330+
},
325331
"https://www.rfc-editor.org/rfc/rfc6454",
326332
"https://www.rfc-editor.org/rfc/rfc6797",
327333
"https://www.rfc-editor.org/rfc/rfc7034",

Diff for: src/compute-shorttitle.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ module.exports = function (title) {
2020
return title;
2121
}
2222

23-
const level = title.match(/\s(\d+(\.\d+)?)$/);
23+
// Handle HTTP/1.1 specs separately to preserve feature name after "HTTP/1.1"
24+
const httpStart = 'Hypertext Transfer Protocol (HTTP/1.1): ';
25+
if (title.startsWith(httpStart)) {
26+
return 'HTTP/1.1 ' + title.substring(httpStart.length);
27+
}
2428

29+
const level = title.match(/\s(\d+(\.\d+)?)$/);
2530
const shortTitle = title
2631
.replace(/\s/g, ' ') // Replace non-breaking spaces
2732
.replace(/ \d+(\.\d+)?$/, '') // Drop level number for now
2833
.replace(/( -)? Level$/, '') // Drop "Level"
2934
.replace(/ Module$/, '') // Drop "Module" (now followed by level)
35+
.replace(/ Proposal$/, '') // Drop "Proposal" (TC39 proposals)
3036
.replace(/ Specification$/, '') // Drop "Specification"
3137
.replace(/ Standard$/, '') // Drop "Standard" and "Living Standard"
3238
.replace(/ Living$/, '')

Diff for: test/compute-shorttitle.js

+12
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,16 @@ describe("compute-shorttitle module", () => {
8484
"Edition Module Standard Foo",
8585
"Edition Module Standard Foo");
8686
});
87+
88+
it("drops 'Proposal' from end of title", () => {
89+
assertTitle(
90+
"Hello world API Proposal",
91+
"Hello world API");
92+
});
93+
94+
it("preserves scope in HTTP/1.1 spec titles", () => {
95+
assertTitle(
96+
"Hypertext Transfer Protocol (HTTP/1.1): Foo bar",
97+
"HTTP/1.1 Foo bar")
98+
});
8799
});

0 commit comments

Comments
 (0)