Skip to content

Commit

Permalink
fix: hash loads json spec (#160)
Browse files Browse the repository at this point in the history
* fix: resolveUrl hash

* test: case for hash loads json spec

* fix: split 1

Co-authored-by: Gürgün Dayıoğlu <hey@gurgun.day>
Signed-off-by: Chun-Wei Chang <50546951+blue86321@users.noreply.github.com>

---------

Signed-off-by: Chun-Wei Chang <50546951+blue86321@users.noreply.github.com>
Co-authored-by: Gürgün Dayıoğlu <hey@gurgun.day>
  • Loading branch information
2 people authored and mcollina committed Jul 19, 2024
1 parent c026dd0 commit 1f36cee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions e2e/custom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
1 change: 1 addition & 0 deletions lib/swagger-initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1f36cee

Please sign in to comment.