★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/1625329fbfNouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files
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 <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>
  • Loading branch information
Trott authored and targos committed Nov 28, 2018
1 parent abb1c64 commit 1625329fbfc17fbeeb0932b58cbf24b71927129a
Showing with 9 additions and 1 deletion.
  1. +6 −1 test/doctool/test-doctool-html.js
  2. +2 −0 test/fixtures/altdocs.md
  3. +1 −0 tools/doc/html.js
@@ -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=/old?u=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fcommit%2F%26quot%3Bhttps%3A%2Fnodejs.org%2Fdocs%2Flatest-v8.x%2Fapi%2Ffoo.html%26quot%3B%26gt%3B8.x%26%2339%3B%3C%2Fspan&y=1999>,
},
];

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}`);
})
);
}));
@@ -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;
}

0 comments on commit 1625329

Please sign in to comment.