11import parseAuthor from 'parse-author' ;
2- import _ from 'lodash' ;
32import { fromPromise } from 'universalify' ;
43
54import * as getComponentFallback from './helpers/get-component-fallback' ;
@@ -11,19 +10,14 @@ import { Component, Config } from '../../types';
1110import { Request , Response } from 'express' ;
1211
1312function getParams ( component : Component ) {
14- let params = { } ;
13+ let params : Record < string , string > = { } ;
1514 if ( component . oc . parameters ) {
16- const mandatoryParams = _ . filter (
17- Object . keys ( component . oc . parameters || { } ) ,
18- paramName => {
19- const param = component . oc . parameters [ paramName ] ;
20- return ! ! param . mandatory && ! ! param . example ;
21- }
22- ) ;
23-
24- params = _ . mapValues (
25- _ . pick ( component . oc . parameters , mandatoryParams ) ,
26- x => x . example
15+ params = Object . fromEntries (
16+ Object . entries ( component . oc . parameters || { } )
17+ . filter ( ( [ , param ] ) => {
18+ return ! ! param . mandatory && 'example' in param ;
19+ } )
20+ . map ( ( [ paramName , param ] ) => [ paramName , param . example ! ] )
2721 ) ;
2822 }
2923
@@ -60,11 +54,10 @@ function componentInfo(
6054 const parsedAuthor = getParsedAuthor ( component ) ;
6155 let href = res . conf . baseUrl ;
6256
63- const repositoryUrl = _ . get (
64- component ,
65- 'repository.url' ,
66- typeof component . repository === 'string' ? component . repository : null
67- ) ;
57+ const repositoryUrl =
58+ typeof component . repository === 'string'
59+ ? component . repository
60+ : component . repository ?. url ?? null ;
6861
6962 fromPromise ( isUrlDiscoverable ) ( href , ( _err , result ) => {
7063 if ( ! result . isDiscoverable ) {
0 commit comments