start_cfi startswith / so dont create a double slash

Also fix tests for highlight sorting
This commit is contained in:
Kovid Goyal 2021-03-15 11:43:46 +05:30
parent 6595e00a19
commit 95ef1423d4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 4 deletions

View File

@ -20,7 +20,7 @@ def highlight_get_cfi(hl):
cfi = hl.start_cfi
if cfi:
si = f'/{hl.spine_index}' if hl.spine_index? else no_cfi
return f'{si}/{cfi}'
return f'{si}{cfi}'
return no_cfi

View File

@ -8,15 +8,15 @@ from testing import assert_equal, test, assert_true
def bm(title, bmid, year=20, first_cfi_number=1):
return {
'title': title, 'id': bmid, 'timestamp': str.format('20{}-06-29T03:21:48.895323+00:00', year),
'title': title, 'id': bmid, 'timestamp': f'20{year}-06-29T03:21:48.895323+00:00',
'pos_type': 'epubcfi', 'pos': str.format('epubcfi(/{}/4/8)', first_cfi_number)
}
def hl(uuid, hlid, year=20, first_cfi_number=1):
return {
'uuid': uuid, 'id': hlid, 'timestamp': str.format('20{}-06-29T03:21:48.895323+00:00', year),
'start_cfi': str.format('epubcfi(/{}/4/8)', first_cfi_number)
'uuid': uuid, 'id': hlid, 'timestamp': f'20{year}-06-29T03:21:48.895323+00:00',
'start_cfi': '/4/8', 'spine_index': first_cfi_number
}