Skip to content

Commit 1f36cee

Browse files
blue86321gurgunday
authored andcommitted
fix: hash loads json spec (#160)
* fix: resolveUrl hash * test: case for hash loads json spec * fix: split 1 Co-authored-by: Gürgün Dayıoğlu <[email protected]> Signed-off-by: Chun-Wei Chang <[email protected]> --------- Signed-off-by: Chun-Wei Chang <[email protected]> Co-authored-by: Gürgün Dayıoğlu <[email protected]>
1 parent c026dd0 commit 1f36cee

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

e2e/custom.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,13 @@ test.describe('Check redirection and url handling of static assets', () => {
7878
const jsonResponse = await jsonResponsePromise
7979
expect(jsonResponse.ok()).toBe(true)
8080
})
81+
82+
test('Check root UI with hash loads json spec', async ({ page }) => {
83+
const jsonResponsePromise = page.waitForResponse(/json/)
84+
await page.goto(`${URL_DOCUMENTATION}#default/get_example`)
85+
86+
// Check if the page has requested the json spec, and if so has it succeeded
87+
const jsonResponse = await jsonResponsePromise
88+
expect(jsonResponse.ok()).toBe(true)
89+
})
8190
})

lib/swagger-initializer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function swaggerInitializer (opts) {
2929
}
3030
function resolveUrl(url) {
3131
var currentHref = window.location.href;
32+
currentHref = currentHref.split('#', 1)[0];
3233
currentHref = currentHref.endsWith('/') ? currentHref : currentHref + '/';
3334
var anchor = document.createElement('a');
3435
anchor.href = currentHref + url;

0 commit comments

Comments
 (0)