diff --git a/e2e/custom.test.js b/e2e/custom.test.js index da1c781..4b345ea 100644 --- a/e2e/custom.test.js +++ b/e2e/custom.test.js @@ -78,4 +78,13 @@ test.describe('Check redirection and url handling of static assets', () => { const jsonResponse = await jsonResponsePromise expect(jsonResponse.ok()).toBe(true) }) + + test('Check root UI with hash loads json spec', async ({ page }) => { + const jsonResponsePromise = page.waitForResponse(/json/) + await page.goto(`${URL_DOCUMENTATION}#default/get_example`) + + // Check if the page has requested the json spec, and if so has it succeeded + const jsonResponse = await jsonResponsePromise + expect(jsonResponse.ok()).toBe(true) + }) }) diff --git a/lib/swagger-initializer.js b/lib/swagger-initializer.js index 40e8165..addcae6 100644 --- a/lib/swagger-initializer.js +++ b/lib/swagger-initializer.js @@ -29,6 +29,7 @@ function swaggerInitializer (opts) { } function resolveUrl(url) { var currentHref = window.location.href; + currentHref = currentHref.split('#', 1)[0]; currentHref = currentHref.endsWith('/') ? currentHref : currentHref + '/'; var anchor = document.createElement('a'); anchor.href = currentHref + url;