Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
  • Loading branch information
Trott committed Nov 25, 2018
commit cba8b242f5a664ff0c652689ce3dfcd070b3d46d
7 changes: 6 additions & 1 deletion test/doctool/test-doctool-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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><ahref="https://nodejs.org/docs/latest-v8.x/api/foo.html">8.x',
Comment thread
Trott marked this conversation as resolved.
Outdated
},
];

const spaces = /\s/g;
Expand All @@ -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}`);
})
);
}));
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/altdocs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ALTDOCS
<!--introduced_in=v8.4.0-->

1 change: 1 addition & 0 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down