diff --git a/website/src/utils/available-in-current-version.js b/website/src/utils/available-in-current-version.js index e7b303e237..ce10fc822a 100644 --- a/website/src/utils/available-in-current-version.js +++ b/website/src/utils/available-in-current-version.js @@ -5,6 +5,16 @@ export const availableInCurrentVersion = ( firstVersion = "0", lastVersion = undefined ) => { + // If `firstVersion` prop set on VersionBlock component without a value, + // it defaults to boolean `true`. This overrides to ensure `firstVersion` is string. + if(typeof firstVersion === "boolean") { + firstVersion = "0" + } + // Do the same to ensure `lastVersion` cannot be a boolean + if (typeof lastVersion === "boolean") { + lastVersion = undefined; + } + // Get versions sorted from earliest to latest const sortedVersions = sortVersions([ currentVersion, diff --git a/website/src/utils/sort-versions.js b/website/src/utils/sort-versions.js index 6e04998730..9b713462e3 100644 --- a/website/src/utils/sort-versions.js +++ b/website/src/utils/sort-versions.js @@ -11,6 +11,9 @@ export const sortVersions = (versionsArr) => { // A positive value indicates that a should come after b. // Zero or NaN indicates that a and b are considered equal. + // Ensure compare items are strings which can be split + if(!a?.length || !b?.length) return null + // Split versions into arrays by decimal // split into max 3 length array (major, minor, patch versions) const aSegments = a?.split(".", 3);