chore: optimize verification: browser or server

This commit is contained in:
Andriy Leliv 2021-04-07 16:09:43 +03:00
parent 7d44e6bdfb
commit 0acef35775

View File

@ -2,14 +2,14 @@
import { convertObj } from 'swagger2openapi';
import { OpenAPISpec } from '../types';
import { Source, Document, bundle, Config, RawConfig } from '@redocly/openapi-core';
import { IS_BROWSER } from './dom';
export async function loadAndBundleSpec(specUrlOrObject: object | string): Promise<OpenAPISpec> {
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
const rawConfig: RawConfig = {};
const config = new Config(rawConfig);
const bundleOpts = {
config,
base: isNode ? process.cwd() : window.location.href
base: IS_BROWSER ? window.location.href : process.cwd()
}
if (typeof specUrlOrObject === 'object' && specUrlOrObject !== null) {