diff --git a/src/BookNavigator/book-navigator.js b/src/BookNavigator/book-navigator.js index 29f4d9be7..85ac3271d 100644 --- a/src/BookNavigator/book-navigator.js +++ b/src/BookNavigator/book-navigator.js @@ -105,6 +105,7 @@ export class BookNavigator extends LitElement { if (changed.has('sharedObserver') && this.bookreader) { this.loadSharedObserver(); + this.initializeBookSubmenus(); } } @@ -461,11 +462,16 @@ export class BookNavigator extends LitElement { this.brHeight = contentRect.height; } + if (!startBrWidth && this.brWidth) { + // loading up, let's update side menus + this.initializeBookSubmenus(); + } + const widthChange = startBrWidth !== this.brWidth; const heightChange = startBrHeight !== this.brHeight; if (!animating && (widthChange || heightChange)) { - this.bookreader.resize(); + this.bookreader?.resize(); } } diff --git a/src/plugins/url/UrlPlugin.js b/src/plugins/url/UrlPlugin.js index 8f96c4a5e..edf9336dd 100644 --- a/src/plugins/url/UrlPlugin.js +++ b/src/plugins/url/UrlPlugin.js @@ -140,7 +140,7 @@ export class UrlPlugin { const concatenatedPath = urlStrPath !== '/' ? urlStrPath : ''; if (this.urlMode == 'history') { if (window.history && window.history.replaceState) { - const newUrlPath = `${this.urlHistoryBasePath}${concatenatedPath}`; + const newUrlPath = `${this.urlHistoryBasePath}${concatenatedPath}`.trim().replace(/(\/+)/g, '/'); window.history.replaceState({}, null, newUrlPath); } } else { diff --git a/tests/jest/plugins/url/UrlPlugin.test.js b/tests/jest/plugins/url/UrlPlugin.test.js index 1049058ec..6ef230230 100644 --- a/tests/jest/plugins/url/UrlPlugin.test.js +++ b/tests/jest/plugins/url/UrlPlugin.test.js @@ -170,6 +170,21 @@ describe('UrlPlugin tests', () => { const locationUrl = `${window.location.pathname}${window.location.search}`; expect(locationUrl).toEqual('/details/foo/page/12?q=hello&view=theater'); }); + + test('strips leading slash of incoming path name for no double slash', () => { + const urlPlugin = new UrlPlugin(); + urlPlugin.urlMode = 'history'; + + urlPlugin.urlHistoryBasePath = '/details/SubBookTest/book1/GPORFP/'; + urlPlugin.urlState = { + "mode": "1up", + }; + + urlPlugin.setUrlParam('sort', 'title_asc'); + urlPlugin.setUrlParam('mode', 'thumb'); + + expect(window.location.href).toEqual('http://localhost/details/SubBookTest/book1/GPORFP/mode/thumb?sort=title_asc'); + }); }); }); diff --git a/tests/karma/BookNavigator/book-navigator.test.js b/tests/karma/BookNavigator/book-navigator.test.js index cf6ae6a32..26dff8c20 100644 --- a/tests/karma/BookNavigator/book-navigator.test.js +++ b/tests/karma/BookNavigator/book-navigator.test.js @@ -323,6 +323,10 @@ describe('', () => { const el = fixtureSync(container()); const brStub = { resize: sinon.fake(), + options: {}, + refs: { + $brContainer: document.createElement('div') + } }; el.bookreader = brStub; await elementUpdated(el); @@ -349,7 +353,12 @@ describe('', () => { const brStub = { animating: false, resize: sinon.fake(), + options: {}, + refs: { + $brContainer: document.createElement('div') + } }; + el.bookreader = brStub; await elementUpdated(el); expect(el.brWidth).to.equal(0);