revise readURL to handle one-based indices

This commit is contained in:
Hakim El Hattab 2018-04-16 09:58:03 +02:00
parent 531d1e8791
commit 2a57223939
1 changed files with 7 additions and 4 deletions

View File

@ -2281,8 +2281,9 @@
} }
// Otherwise use the /h/v index // Otherwise use the /h/v index
else { else {
if( indexh > 0 || indexv > 0 || indexf !== undefined ) url += indexh + config.hashOneBasedIndex; var hashIndexBase = config.hashOneBasedIndex ? 1 : 0;
if( indexv > 0 || indexf !== undefined ) url += '/' + (indexv + config.hashOneBasedIndex); if( indexh > 0 || indexv > 0 || indexf !== undefined ) url += indexh + hashIndexBase;
if( indexv > 0 || indexf !== undefined ) url += '/' + (indexv + hashIndexBase );
if( indexf !== undefined ) url += '/' + indexf; if( indexf !== undefined ) url += '/' + indexf;
} }
@ -3839,9 +3840,11 @@
} }
} }
else { else {
var hashIndexBase = config.hashOneBasedIndex ? 1 : 0;
// Read the index components of the hash // Read the index components of the hash
var h = parseInt( bits[0], 10 ) || 0 - config.hashOneBasedIndex, var h = ( parseInt( bits[0], 10 ) - hashIndexBase ) || 0,
v = parseInt( bits[1], 10 ) || 0 - config.hashOneBasedIndex, v = ( parseInt( bits[1], 10 ) - hashIndexBase ) || 0,
f; f;
if( config.fragmentInURL ) { if( config.fragmentInURL ) {