mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
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: https://github.com/nodejs/node/issues/23979 PR-URL: https://github.com/nodejs/node/pull/24638 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
This commit is contained in:
parent
cc399cf5b2
commit
6f64cda1ee
@ -95,6 +95,10 @@ const testData = [
|
||||
html: '<ol><li>fish</li><li>fish</li></ol>' +
|
||||
'<ul><li>Red fish</li><li>Blue fish</li></ul>',
|
||||
},
|
||||
{
|
||||
file: fixtures.path('altdocs.md'),
|
||||
html: '<li><a href="https://nodejs.org/docs/latest-v8.x/api/foo.html">8.x',
|
||||
},
|
||||
];
|
||||
|
||||
const spaces = /\s/g;
|
||||
@ -117,7 +121,8 @@ testData.forEach(({ file, html }) => {
|
||||
const actual = output.replace(spaces, '');
|
||||
// Assert that the input stripped of all whitespace contains the
|
||||
// expected markup.
|
||||
assert(actual.includes(expected));
|
||||
assert(actual.includes(expected),
|
||||
`ACTUAL: ${actual}\nEXPECTED: ${expected}`);
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
2
test/fixtures/altdocs.md
vendored
Normal file
2
test/fixtures/altdocs.md
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# ALTDOCS
|
||||
<!--introduced_in=v8.4.0-->
|
@ -427,6 +427,7 @@ function altDocs(filename, docCreated) {
|
||||
const [versionMajor, versionMinor] = version.num.split('.').map(Number);
|
||||
if (docCreatedMajor > versionMajor) return false;
|
||||
if (docCreatedMajor < versionMajor) return true;
|
||||
if (Number.isNaN(versionMinor)) return true;
|
||||
return docCreatedMinor <= versionMinor;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user