Skip to content

Commit

Permalink
fix(audits/server): url option can also just be a Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Nov 21, 2022
1 parent 370fca5 commit 8844aea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/interfaces/audits_server.ServerAuditOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ___

### url

**url**: `string` \| () => `string` \| `Promise`<`string`\>
**url**: `string` \| `Promise`<`string`\> \| () => `string` \| `Promise`<`string`\>

The URL of the GraphQL server for the audit.

Expand Down
10 changes: 5 additions & 5 deletions src/audits/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface ServerAuditOptions {
* A function can be also supplied, in this case -
* every audit will invoke the function to get the URL.
*/
url: string | (() => string | Promise<string>);
url: string | Promise<string> | (() => string | Promise<string>);
/**
* The Fetch function to use.
*
Expand Down Expand Up @@ -950,10 +950,10 @@ export async function auditServer(

/** @private */
async function getUrl(
url: string | (() => string | Promise<string>),
url: string | Promise<string> | (() => string | Promise<string>),
): Promise<string> {
if (typeof url === 'string') {
return url;
if (typeof url === 'function') {
return await url();
}
return await url();
return url;
}

0 comments on commit 8844aea

Please sign in to comment.