File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ type contentType =
1010 | @as ("lvl6" ) Lvl6
1111
1212type hierarchy = {
13- lvl0 : string ,
14- lvl1 : string ,
13+ lvl0 : Nullable . t < string > ,
14+ lvl1 : Nullable . t < string > ,
1515 lvl2 : Nullable .t <string >,
1616 lvl3 : Nullable .t <string >,
1717 lvl4 : Nullable .t <string >,
Original file line number Diff line number Diff line change @@ -59,13 +59,25 @@ let transformItems = (items: DocSearch.transformItems) => {
5959 | Some ({pathname , hash }) =>
6060 RegExp .test (/ v (8 |9 |10 |11 )\./ , pathname )
6161 ? None
62- : Some ({
63- ... item ,
64- deprecated : pathname -> String .includes ("api/js" ) || pathname -> String .includes ("api/core" )
65- ? Some ("Deprecated" )
66- : None ,
67- url : pathname -> String .replace ("/v12.0.0/" , "/" ) ++ hash ,
68- })
62+ : {
63+ // DocSearch internally calls .replace() on hierarchy.lvl1, so we must
64+ // provide a fallback for items where lvl1 is null to prevent crashes
65+ let hierarchy = item .hierarchy
66+ let lvl0 = hierarchy .lvl0 -> Nullable .toOption -> Option .getOr ("" )
67+ let lvl1 = hierarchy .lvl1 -> Nullable .toOption -> Option .getOr (lvl0 )
68+ Some ({
69+ ... item ,
70+ deprecated : pathname -> String .includes ("api/js" ) || pathname -> String .includes ("api/core" )
71+ ? Some ("Deprecated" )
72+ : None ,
73+ url : pathname -> String .replace ("/v12.0.0/" , "/" ) ++ hash ,
74+ hierarchy : {
75+ ... hierarchy ,
76+ lvl0 : Nullable .make (lvl0 ),
77+ lvl1 : Nullable .make (lvl1 ),
78+ },
79+ })
80+ }
6981 | None => None
7082 }
7183 })
You can’t perform that action at this time.
0 commit comments