UNPKG

@scalar/oas-utils

Version:

Open API spec and Yaml handling utilities

28 lines (27 loc) 846 B
import { mergeUrls } from "@scalar/helpers/url/merge-urls"; import { replaceVariables } from "@scalar/helpers/regex/replace-variables"; const processServerUrl = (server, path) => { if (!server.url) { return path; } const serverUrl = server.url; if (server.variables) { const variables = Object.entries(server.variables); const defaultValues = variables.reduce( (defaults, [variableName, variableConfig]) => { if (variableConfig.default !== void 0) { defaults[variableName] = variableConfig.default; } return defaults; }, {} ); const serverUrlWithVars = replaceVariables(serverUrl, defaultValues); return mergeUrls(serverUrlWithVars, path); } return mergeUrls(serverUrl, path); }; export { processServerUrl }; //# sourceMappingURL=process-server-url.js.map