Skip to content

Commit f9933ff

Browse files
TrottBethGriggs
authored andcommitted
tools,doc: fix version picker bug in html.js
The processing of strings like `8.x` into a major version number and a minor version number results in minor versions that are `NaN`. In that situation, since the picker will link to the latest docs in the major version, include the version in the version picker. Fixes: #23979 PR-URL: #24638 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
1 parent 7dee5e5 commit f9933ff

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

test/doctool/test-doctool-html.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ const testData = [
9595
html: '<ol><li>fish</li><li>fish</li></ol>' +
9696
'<ul><li>Red fish</li><li>Blue fish</li></ul>',
9797
},
98+
{
99+
file: fixtures.path('altdocs.md'),
100+
html: '<li><a href="https://nodejs.org/docs/latest-v8.x/api/foo.html">8.x',
101+
},
98102
];
99103

100104
const spaces = /\s/g;
@@ -117,7 +121,8 @@ testData.forEach(({ file, html }) => {
117121
const actual = output.replace(spaces, '');
118122
// Assert that the input stripped of all whitespace contains the
119123
// expected markup.
120-
assert(actual.includes(expected));
124+
assert(actual.includes(expected),
125+
`ACTUAL: ${actual}\nEXPECTED: ${expected}`);
121126
})
122127
);
123128
}));

test/fixtures/altdocs.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ALTDOCS
2+
<!--introduced_in=v8.4.0-->

tools/doc/html.js

+1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ function altDocs(filename, docCreated) {
427427
const [versionMajor, versionMinor] = version.num.split('.').map(Number);
428428
if (docCreatedMajor > versionMajor) return false;
429429
if (docCreatedMajor < versionMajor) return true;
430+
if (Number.isNaN(versionMinor)) return true;
430431
return docCreatedMinor <= versionMinor;
431432
}
432433

0 commit comments

Comments
 (0)