@@ -144,7 +144,8 @@ BookReader.prototype.urlUpdateFragment = function() {
144144 const currFragment = this . urlReadFragment ( ) ;
145145 const currQueryString = this . getLocationSearch ( ) ;
146146 const newQueryString = this . queryStringFromParams ( params , currQueryString , this . options . urlMode ) ;
147- if ( currFragment === newFragment && currQueryString === newQueryString ) {
147+ const hasTextParam = currQueryString . includes ( "text" ) ;
148+ if ( currFragment === newFragment && currQueryString === newQueryString && ! hasTextParam ) {
148149 return ;
149150 }
150151
@@ -154,11 +155,21 @@ BookReader.prototype.urlUpdateFragment = function() {
154155 } else {
155156 const baseWithoutSlash = this . options . urlHistoryBasePath . replace ( / \/ + $ / , '' ) ;
156157 const newFragmentWithSlash = newFragment === '' ? '' : `/${ newFragment } ` ;
157-
158+ let textFragment = ""
159+ if ( this . urlPlugin . retrieveTextFragment ( newQueryString ) ) {
160+ textFragment = this . urlParamsFiltersOnlySearch ( this . readQueryString ( ) ) ;
161+ // newQueryString = newQueryString.replace(this.urlPlugin.retrieveTextFragment(newQueryString)[0], "").replace(/(\?text=)/, "")
162+ }
163+ console . log ( "this is newQueryString" , newQueryString ) ;
158164 const newUrlPath = `${ baseWithoutSlash } ${ newFragmentWithSlash } ${ newQueryString } ` ;
165+ console . log ( "this is newURLPath" , newUrlPath ) ;
159166 try {
160167 window . history . replaceState ( { } , null , newUrlPath ) ;
161168 this . oldLocationHash = newFragment + newQueryString ;
169+ if ( textFragment ) {
170+ window . location . replace ( '#' + textFragment ) ;
171+ this . oldLocationHash = textFragment ;
172+ }
162173 } catch ( e ) {
163174 // DOMException on Chrome when in sandboxed iframe
164175 this . options . urlMode = 'hash' ;
@@ -199,6 +210,7 @@ BookReader.prototype.urlParamsFiltersOnlySearch = function(url) {
199210BookReader . prototype . urlReadFragment = function ( ) {
200211 const { urlMode, urlHistoryBasePath } = this . options ;
201212 if ( urlMode === 'history' ) {
213+ console . log ( "within plugin.url" , window . location ) ;
202214 return window . location . pathname . substr ( urlHistoryBasePath . length ) ;
203215 } else {
204216 return this . urlPlugin . getHash ( ) ;
@@ -219,6 +231,7 @@ export class BookreaderUrlPlugin extends BookReader {
219231 const location = this . getLocationSearch ( ) ;
220232 if ( location . includes ( "text=" ) ) {
221233 this . on ( 'textLayerRendered' , ( _ , { pageIndex, container} ) => {
234+ console . log ( "line 235 plugin.url.js window.location.replace" , `#${ this . oldLocationHash } ` ) ;
222235 window . location . replace ( `#${ this . oldLocationHash } ` ) ;
223236 } ) ;
224237 }
0 commit comments