@@ -687,49 +687,46 @@ export function updateURL(translation, book, chapter) {
687687 const cleanBook = bookAbbr . toLowerCase ( ) ;
688688 const cleanChapter = Math . max ( 1 , parseInt ( chapter ) || 1 ) ;
689689
690- const newURL = `#/${ cleanTranslation } /${ cleanBook } /${ cleanChapter } ` ;
691- window . location . hash = newURL ;
690+ const newQuery = `?p=${ cleanTranslation } /${ cleanBook } /${ cleanChapter } ` ;
691+ if ( window . location . search !== newQuery ) {
692+ window . history . replaceState ( { } , '' , newQuery ) ;
693+ }
692694}
693695
696+
694697/**
695698 * Parse URL parameters to extract translation, book, and chapter
696699 * @returns {Object|null } Object with translation, book, chapter or null if invalid
697700 */
698701export function parseURL ( ) {
699- const path = window . location . hash ? window . location . hash . substring ( 1 ) : window . location . pathname ;
700- if ( path === '/' || path === '' ) {
702+ const urlParams = new URLSearchParams ( window . location . search ) ;
703+ const path = urlParams . get ( 'p' ) ;
704+
705+ if ( ! path ) {
701706 return null ;
702707 }
703708
704709 const pathParts = path . split ( '/' ) . filter ( part => part !== '' ) ;
710+
705711 if ( pathParts . length >= 3 ) {
706712 const translation = pathParts [ 0 ] . toUpperCase ( ) ;
707713 let bookAbbreviation = pathParts [ 1 ] . toUpperCase ( ) ;
708714 const chapter = parseInt ( pathParts [ 2 ] , 10 ) ;
709715
710- // Convert abbreviation to full book name
711716 const book = ABBREVIATION_TO_BOOK_NAME [ bookAbbreviation ] ;
712717
713718 if ( ! book ) {
714- console . warn ( 'Invalid book abbreviation in URL :' , bookAbbreviation ) ;
719+ console . warn ( 'Invalid book abbreviation in query :' , bookAbbreviation ) ;
715720 return null ;
716721 }
717722
718- // Validate translation
719723 if ( ! AVAILABLE_TRANSLATIONS . includes ( translation ) ) {
720- console . warn ( 'Invalid translation in URL:' , translation ) ;
721- return null ;
722- }
723-
724- // Validate book (using the full name)
725- if ( ! BOOKS_ABBREVIATED . includes ( bookAbbreviation ) ) {
726- console . warn ( 'Invalid book in URL:' , book ) ;
724+ console . warn ( 'Invalid translation in query:' , translation ) ;
727725 return null ;
728726 }
729727
730- // Validate chapter
731728 if ( isNaN ( chapter ) || chapter <= 0 || chapter > 150 ) {
732- console . warn ( 'Invalid chapter in URL :' , chapter ) ;
729+ console . warn ( 'Invalid chapter in query :' , chapter ) ;
733730 return null ;
734731 }
735732
0 commit comments