mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 00:26:34 +03:00
fix: wrong base url format causing error when constructing new URL (#1996)
Co-authored-by: Andrew Tatomyr <andrew.tatomyr@redocly.com> Co-authored-by: Alex Varchuk <olexandr.varchuk@gmail.com> Co-authored-by: Anastasiia Derymarko <anastasiia@redocly.com>
This commit is contained in:
parent
311d2ce64d
commit
d2cdaa1221
|
@ -5,7 +5,7 @@ describe('build', () => {
|
||||||
it('should use .redocly.yaml', () => {
|
it('should use .redocly.yaml', () => {
|
||||||
const r = spawnSync(
|
const r = spawnSync(
|
||||||
'ts-node',
|
'ts-node',
|
||||||
['../../../index.ts', 'build', ' ../../../../demo/openapi.yaml', '--output=redocTest.html'],
|
['../../../index.ts', 'build', ' ../../../../demo/openapi.yaml', '--output=redoc-test.html'],
|
||||||
{
|
{
|
||||||
cwd: __dirname,
|
cwd: __dirname,
|
||||||
shell: true,
|
shell: true,
|
||||||
|
@ -17,7 +17,7 @@ describe('build', () => {
|
||||||
const result = `${out}\n${err}`;
|
const result = `${out}\n${err}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const redocStaticFile = readFileSync(`${__dirname}/redocTest.html`, 'utf8');
|
const redocStaticFile = readFileSync(`${__dirname}/redoc-test.html`, 'utf8');
|
||||||
expect(redocStaticFile).toContain('"options":{"disableSearch":true}');
|
expect(redocStaticFile).toContain('"options":{"disableSearch":true}');
|
||||||
expect(redocStaticFile).not.toContain('role="search"');
|
expect(redocStaticFile).not.toContain('role="search"');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
25
cli/__test__/build/configRedoc/url.test.ts
Normal file
25
cli/__test__/build/configRedoc/url.test.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
|
||||||
|
describe('build with url', () => {
|
||||||
|
// FIXME: remove skip after release
|
||||||
|
it.skip('should not fail on resolving url', () => {
|
||||||
|
const r = spawnSync(
|
||||||
|
'ts-node',
|
||||||
|
[
|
||||||
|
'../../../index.ts',
|
||||||
|
'build',
|
||||||
|
'http://petstore.swagger.io/v2/swagger.json',
|
||||||
|
'--output=url-test.html',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cwd: __dirname,
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const out = r.stdout.toString('utf-8');
|
||||||
|
const err = r.stderr.toString('utf-8');
|
||||||
|
const result = `${out}\n${err}`;
|
||||||
|
expect(result).toContain('bundled successfully');
|
||||||
|
});
|
||||||
|
});
|
|
@ -58,7 +58,7 @@ export class OpenAPIParser {
|
||||||
this.spec = spec;
|
this.spec = spec;
|
||||||
this.allowMergeRefs = spec.openapi.startsWith('3.1');
|
this.allowMergeRefs = spec.openapi.startsWith('3.1');
|
||||||
|
|
||||||
const href = IS_BROWSER ? window.location.href : '';
|
const href = IS_BROWSER ? window.location.href : undefined;
|
||||||
if (typeof specUrl === 'string') {
|
if (typeof specUrl === 'string') {
|
||||||
this.specUrl = new URL(specUrl, href).href;
|
this.specUrl = new URL(specUrl, href).href;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export class ExampleModel {
|
||||||
this.summary = example.summary;
|
this.summary = example.summary;
|
||||||
this.description = example.description;
|
this.description = example.description;
|
||||||
if (example.externalValue) {
|
if (example.externalValue) {
|
||||||
this.externalValueUrl = new URL(example.externalValue, parser.specUrl || '').href;
|
this.externalValueUrl = new URL(example.externalValue, parser.specUrl).href;
|
||||||
}
|
}
|
||||||
parser.exitRef(infoOrRef);
|
parser.exitRef(infoOrRef);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user