File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ type LookupCallback = (
2121 family ?: number ,
2222) => void ;
2323
24+ type LookupResult = LookupAddress | readonly LookupAddress [ ] ;
25+
2426export class SsrFBlockedError extends Error {
2527 constructor ( message : string ) {
2628 super ( message ) ;
@@ -200,6 +202,10 @@ function assertAllowedResolvedAddressesOrThrow(
200202 }
201203}
202204
205+ function normalizeLookupResults ( results : LookupResult ) : readonly LookupAddress [ ] {
206+ return Array . isArray ( results ) ? results : [ results ] ;
207+ }
208+
203209export function createPinnedLookup ( params : {
204210 hostname : string ;
205211 addresses : string [ ] ;
@@ -331,7 +337,9 @@ export async function resolvePinnedHostnameWithPolicy(
331337 }
332338
333339 const lookupFn = params . lookupFn ?? dnsLookup ;
334- const results = await lookupFn ( normalized , { all : true } ) ;
340+ const results = normalizeLookupResults (
341+ ( await lookupFn ( normalized , { all : true } ) ) as LookupResult ,
342+ ) ;
335343 if ( results . length === 0 ) {
336344 throw new Error ( `Unable to resolve hostname: ${ hostname } ` ) ;
337345 }
You can’t perform that action at this time.
0 commit comments