@@ -57,6 +57,7 @@ import {
5757 shadow ,
5858 stopEvent ,
5959 TouchManager ,
60+ updateUrlHash ,
6061 version ,
6162} from "pdfjs-lib" ;
6263import { AppOptions , OptionKind } from "./app_options.js" ;
@@ -943,10 +944,18 @@ const PDFViewerApplication = {
943944
944945 setTitleUsingUrl ( url = "" , downloadUrl = null ) {
945946 this . url = url ;
946- this . baseUrl = url . split ( "#" , 1 ) [ 0 ] ;
947+ this . baseUrl =
948+ typeof PDFJSDev === "undefined" || PDFJSDev . test ( "GENERIC" )
949+ ? updateUrlHash ( url , "" , /* allowRel = */ true )
950+ : updateUrlHash ( url , "" ) ;
947951 if ( downloadUrl ) {
948952 this . _downloadUrl =
949- downloadUrl === url ? this . baseUrl : downloadUrl . split ( "#" , 1 ) [ 0 ] ;
953+ // eslint-disable-next-line no-nested-ternary
954+ downloadUrl === url
955+ ? this . baseUrl
956+ : typeof PDFJSDev === "undefined" || PDFJSDev . test ( "GENERIC" )
957+ ? updateUrlHash ( downloadUrl , "" , /* allowRel = */ true )
958+ : updateUrlHash ( downloadUrl , "" ) ;
950959 }
951960 if ( isDataScheme ( url ) ) {
952961 this . _hideViewBookmark ( ) ;
@@ -1309,7 +1318,7 @@ const PDFViewerApplication = {
13091318 this . secondaryToolbar ?. setPagesCount ( pdfDocument . numPages ) ;
13101319
13111320 if ( typeof PDFJSDev !== "undefined" && PDFJSDev . test ( "CHROME" ) ) {
1312- const baseUrl = location . href . split ( "#" , 1 ) [ 0 ] ;
1321+ const baseUrl = updateUrlHash ( location , "" ) ;
13131322 // Ignore "data:"-URLs for performance reasons, even though it may cause
13141323 // internal links to not work perfectly in all cases (see bug 1803050).
13151324 this . pdfLinkService . setDocument (
0 commit comments