@@ -25,11 +25,10 @@ interface ResolvedEndpoints {
2525
2626let cachedEndpoints : ResolvedEndpoints | null = null
2727
28- async function resolveEndpoints ( userAgent ?: string ) : Promise < ResolvedEndpoints > {
28+ async function resolveEndpoints ( ) : Promise < ResolvedEndpoints > {
2929 if ( cachedEndpoints ) return cachedEndpoints
3030
3131 const resp = await axios . get < ServiceIndex > ( SERVICE_INDEX_URL , {
32- headers : userAgent ? { 'User-Agent' : userAgent } : { } ,
3332 timeout : 10000 ,
3433 } )
3534
@@ -68,9 +67,8 @@ function classifyError(err: unknown): NuGetFetchError | null {
6867
6968export async function fetchSearch (
7069 packageId : string ,
71- userAgent ?: string ,
7270) : Promise < NuGetSearchItem | NuGetFetchError > {
73- const { searchBaseUrl } = await resolveEndpoints ( userAgent )
71+ const { searchBaseUrl } = await resolveEndpoints ( )
7472 const lowerPackageId = packageId . toLowerCase ( )
7573
7674 try {
@@ -82,7 +80,6 @@ export async function fetchSearch(
8280 take : 20 ,
8381 } ,
8482 headers : {
85- ...( userAgent ? { 'User-Agent' : userAgent } : { } ) ,
8683 'Accept-Encoding' : 'gzip' ,
8784 } ,
8885 timeout : 15000 ,
@@ -100,35 +97,25 @@ export async function fetchSearch(
10097 }
10198}
10299
103- async function fetchRegistrationPage (
104- pageId : string ,
105- userAgent ?: string ,
106- ) : Promise < NuGetRegistrationPage > {
100+ async function fetchRegistrationPage ( pageId : string ) : Promise < NuGetRegistrationPage > {
107101 const resp = await axios . get < NuGetRegistrationPage > ( pageId , {
108- headers : {
109- ...( userAgent ? { 'User-Agent' : userAgent } : { } ) ,
110- 'Accept-Encoding' : 'gzip' ,
111- } ,
102+ headers : { 'Accept-Encoding' : 'gzip' } ,
112103 timeout : 15000 ,
113104 } )
114105 return resp . data
115106}
116107
117108export async function fetchRegistration (
118109 packageId : string ,
119- userAgent ?: string ,
120110) : Promise < NuGetRegistrationIndex | NuGetFetchError > {
121- const { registrationBaseUrl } = await resolveEndpoints ( userAgent )
111+ const { registrationBaseUrl } = await resolveEndpoints ( )
122112 const lowerId = packageId . toLowerCase ( )
123113
124114 try {
125115 const resp = await axios . get < NuGetRegistrationIndex > (
126116 `${ registrationBaseUrl } ${ lowerId } /index.json` ,
127117 {
128- headers : {
129- ...( userAgent ? { 'User-Agent' : userAgent } : { } ) ,
130- 'Accept-Encoding' : 'gzip' ,
131- } ,
118+ headers : { 'Accept-Encoding' : 'gzip' } ,
132119 timeout : 15000 ,
133120 } ,
134121 )
@@ -139,7 +126,7 @@ export async function fetchRegistration(
139126 const page = index . items [ i ]
140127 if ( ! page . items ) {
141128 try {
142- const fullPage = await fetchRegistrationPage ( page [ '@id' ] , userAgent )
129+ const fullPage = await fetchRegistrationPage ( page [ '@id' ] )
143130 index . items [ i ] = { ...page , items : fullPage . items ?? [ ] }
144131 } catch {
145132 index . items [ i ] = { ...page , items : [ ] }
0 commit comments