Skip to content

Commit 8942581

Browse files
vsemozhetbytjasnell
authored andcommitted
doc: support multidimensional arrays in type link
Currently, we have at least one multidimensional array in type signature: see `records` parameter in https://nodejs.org/api/dns.html#dns_dns_resolvetxt_hostname_callback Our type parser does not linkify these signatures properly. This PR tries to fix this. PR-URL: #16207 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
1 parent 70896c7 commit 8942581

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tools/doc/type-parser.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ const typeMap = {
5858
'URLSearchParams': 'url.html#url_class_urlsearchparams'
5959
};
6060

61+
const arrayPart = /(?:\[])+$/;
62+
6163
module.exports = {
6264
toLink: function(typeInput) {
6365
const typeLinks = [];
@@ -69,12 +71,10 @@ module.exports = {
6971
if (typeText) {
7072
let typeUrl = null;
7173

72-
// To support type[], we store the full string and use
73-
// the bracket-less version to lookup the type URL
74+
// To support type[], type[][] etc., we store the full string
75+
// and use the bracket-less version to lookup the type URL
7476
const typeTextFull = typeText;
75-
if (/\[]$/.test(typeText)) {
76-
typeText = typeText.slice(0, -2);
77-
}
77+
typeText = typeText.replace(arrayPart, '');
7878

7979
const primitive = jsPrimitives[typeText.toLowerCase()];
8080

0 commit comments

Comments
 (0)