Skip to content

fix: correct footnote verse link format and detect Surah context (#3267) - #3315

Open
Mubashir78 wants to merge 2 commits into
quran:productionfrom
Mubashir78:fix/footnote-verse-link-format
Open

fix: correct footnote verse link format and detect Surah context (#3267)#3315
Mubashir78 wants to merge 2 commits into
quran:productionfrom
Mubashir78:fix/footnote-verse-link-format

Conversation

@Mubashir78

Copy link
Copy Markdown

Summary

Fixes #3267 - Incorrect routing in footnote verse links.

Problem

The formatVerseReferencesToLinks function was creating malformed URLs:

  1. Colon-separated refs like 37:7-10 linked to /37:7-10 instead of /37/7-10
  2. Bare verse ranges like 7-10 linked to /7-10 (routes to wrong Surah) instead of the contextually implied chapter

Changes

src/utils/string.ts:

  • formatVerseReferencesToLinks now splits colon-separated refs into /chapter/verses format
  • Added optional chapterContext parameter for bare verse ranges
  • Added findChapterContext() utility that scans footnote text for transliterated Surah names and returns the corresponding chapter ID

src/components/QuranReader/TranslationView/TranslationText/FootnoteText.tsx:

  • Gets chaptersData from DataContext
  • Calls findChapterContext before formatting to detect the Surah context
  • Passes detected chapter ID to formatVerseReferencesToLinks

Behavior

Input Before After
37:7-10 /37:7-10 (broken) /37/7-10 (correct)
7-10 with "As-Saffat" context /7-10 (wrong) /37/7-10 (correct)
7-10 without context /7-10 (wrong) 7-10 (unlinked, safe)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2befa228f9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/utils/string.ts
Comment thread src/utils/string.ts
@Mubashir78

Copy link
Copy Markdown
Author

I have addressed the concerns raised by the bot. In sha Allah I will be looking to solve as many issues as I can 👍

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