mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-09 22:54:51 +03:00
chore: optimize verification: browser or server
This commit is contained in:
parent
7d44e6bdfb
commit
0acef35775
|
@ -2,14 +2,14 @@
|
||||||
import { convertObj } from 'swagger2openapi';
|
import { convertObj } from 'swagger2openapi';
|
||||||
import { OpenAPISpec } from '../types';
|
import { OpenAPISpec } from '../types';
|
||||||
import { Source, Document, bundle, Config, RawConfig } from '@redocly/openapi-core';
|
import { Source, Document, bundle, Config, RawConfig } from '@redocly/openapi-core';
|
||||||
|
import { IS_BROWSER } from './dom';
|
||||||
|
|
||||||
export async function loadAndBundleSpec(specUrlOrObject: object | string): Promise<OpenAPISpec> {
|
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 rawConfig: RawConfig = {};
|
||||||
const config = new Config(rawConfig);
|
const config = new Config(rawConfig);
|
||||||
const bundleOpts = {
|
const bundleOpts = {
|
||||||
config,
|
config,
|
||||||
base: isNode ? process.cwd() : window.location.href
|
base: IS_BROWSER ? window.location.href : process.cwd()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof specUrlOrObject === 'object' && specUrlOrObject !== null) {
|
if (typeof specUrlOrObject === 'object' && specUrlOrObject !== null) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user