mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
Return empty string if no server provided (#2878)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@gitbook/react-openapi': patch
|
||||
---
|
||||
|
||||
Return empty string if no server provided
|
||||
@@ -50,9 +50,9 @@ describe('#getDefaultServerURL', () => {
|
||||
expect(result).toBe('https://user.example.com/v1');
|
||||
});
|
||||
|
||||
it('returns null if no servers are provided', () => {
|
||||
it('returns empty string if no servers are provided', () => {
|
||||
const servers: OpenAPIV3.ServerObject[] = [];
|
||||
const result = getDefaultServerURL(servers);
|
||||
expect(result).toBeNull();
|
||||
expect(result).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,10 +3,11 @@ import { OpenAPIV3 } from '@gitbook/openapi-parser';
|
||||
/**
|
||||
* Get the default URL for the server.
|
||||
*/
|
||||
export function getDefaultServerURL(servers: OpenAPIV3.ServerObject[]): null | string {
|
||||
export function getDefaultServerURL(servers: OpenAPIV3.ServerObject[]): string {
|
||||
const server = servers[0];
|
||||
if (!server) {
|
||||
return null;
|
||||
// Return empty string if no server is found to display nothing
|
||||
return '';
|
||||
}
|
||||
|
||||
return interpolateServerURL(server);
|
||||
|
||||
Reference in New Issue
Block a user