Skip to content

fix: don't link hyphen-only numeric ranges as verse references - #3293

Open
mahmoodhamdi wants to merge 1 commit into
quran:productionfrom
mahmoodhamdi:fix-footnote-verse-reference-regex
Open

fix: don't link hyphen-only numeric ranges as verse references#3293
mahmoodhamdi wants to merge 1 commit into
quran:productionfrom
mahmoodhamdi:fix-footnote-verse-reference-regex

Conversation

@mahmoodhamdi

Copy link
Copy Markdown

Summary

Closes: #3267

The verse-reference regex used by formatVerseReferencesToLinks (called from
FootnoteText) accepted either : or - as the chapter:verse separator. As
a result, an isolated range like (7-10) inside a translation footnote was
rewritten to /7-10 and routed to Surah 7 — even when the surrounding text
referenced a different Surah (the original report was Hindi Surah Al-Mulk 67:5
referencing As-Saffat 37:7-10).

Tightens the regex to require : between chapter and verse so only
conventional references become links: 1:1, 1:1-3, 1:1-2:3. Bare
hyphen-separated numbers are left as plain text.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Scope Confirmation

  • This PR addresses one feature/fix only

Test Plan

  • Updated the existing "partial verse references" test to expect no link
    for 1-1.
  • Added a regression test for the reported case
    (See Surah As-Saffat, verses (7-10) for context).
  • yarn test — 935 / 935 tests pass.
  • yarn lint on the two changed files — clean.

Manual reproduction (before fix):

  1. Open Surah Al-Mulk 67:5 with the Hindi translation by Maulana Azizul Haque al-Umari enabled.
  2. Open the footnote for the word "शैतानों".
  3. Click the (7-10) hyperlink — currently routes to /7-10 (Surah 7).

After the fix, the (7-10) text remains plain (not linked), so the footnote
no longer misroutes.

Rollback Safety

  • Can be safely reverted without data issues or migrations

The verse-reference regex used by FootnoteText accepted either ":" or "-"
as the chapter:verse separator, so an isolated range like "(7-10)" in a
translation footnote was rewritten to /7-10 and routed to Surah 7 even
when the surrounding text referenced a different Surah.

Restrict the chapter:verse separator to ":" so only conventional
references (1:1, 1:1-3, 1:1-2:3) become links. Bare hyphen-separated
numbers are left as plain text.

Closes quran#3267
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Incorrect routing in Hindi translation footnote link (Surah 67:5)

1 participant