Skip to content

Commit

Permalink
Merge pull request Sefaria#1776 from Sefaria/fix-mekhilta-alt-title-l…
Browse files Browse the repository at this point in the history
…egacy

fix(legacy ref): clean tref of underscores before replacing alt title…
  • Loading branch information
nsantacruz authored Jan 10, 2024
2 parents f7494ac + a8aeaee commit 56bc9f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions sefaria/helper/tests/legacy_ref_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def test_instantiate_ref_with_legacy_parse_fallback(self, url_test_index_title,

@pytest.mark.parametrize(('url_index_title', 'input_title', 'input_sections', 'output_tref'), [
["Test_Zohar", "Alt Title Yo yo", "1:15a:1", "Test_Zohar.1.42"],
["Test_Zohar", "Alt_Title_Yo_yo", "1:15a:1", "Test_Zohar.1.42"],
])
def test_instantiate_legacy_refs_parametrized(url_index_title, input_title, input_sections, output_tref):
old_tref = f"{input_title}.{input_sections}"
Expand Down
2 changes: 1 addition & 1 deletion sefaria/model/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -4873,9 +4873,9 @@ def instantiate_ref_with_legacy_parse_fallback(tref: str) -> 'Ref':
except PartialRefInputError as e:
matched_ref = Ref(e.matched_part)
try:
tref = Ref.__clean_tref(tref, matched_ref._lang)
# replace input title with normalized title in case input was an alt title
tref = tref.replace(e.matched_part, matched_ref.normal())
tref = Ref.__clean_tref(tref, matched_ref._lang)
legacy_ref_parser = legacy_ref_parser_handler[matched_ref.index.title]
return legacy_ref_parser.parse(tref)
except LegacyRefParserError:
Expand Down

0 comments on commit 56bc9f3

Please sign in to comment.