8000 fix: keep the ayah when a quran:// link has a query string by BiskremMuhammad · Pull Request #4070 · quran/quran_android · GitHub
[go: up one dir, main page]

Skip to content

fix: keep the ayah when a quran:// link has a query string - #4070

Open
BiskremMuhammad wants to merge 1 commit into
quran:mainfrom
BiskremMuhammad:fix/deeplink-query-loses-ayah
Open

BiskremMuhammad wants to merge 1 commit into
quran:mainfrom
BiskremMuhammad:fix/deeplink-query-loses-ayah

Conversation

@BiskremMuhammad
Copy link
Copy Markdown

quran://2/255?play=true opens ayah 1, not ayah 255.

QuranForwarderActivity does not parse the uri — it stringifies the whole thing, splits on /, and takes the first two pieces that survive toInt(). With a query string the last piece is 255?play=true, toInt() throws, the catch leaves the value alone, and the ayah keeps its default of 1. There is no error anywhere; the reader simply lands at the top of the sura.

This reads the authority and the path segments off the Uri instead, so the query is out of the numbers by construction.

Nothing else changes: non-numeric pieces are still skipped, so quran://quran.com/2/255 still resolves; a sura on its own still opens at its first ayah; and no validation was added or removed.

Tests

QuranForwarderActivityTest launches the activity and asserts the intent it forwards to QuranDataActivity, in the same style as ShortcutsActivityTest. The two query cases fail on main with ayah 1 instead of 255, and pass here.

./gradlew :app:testMadaniDebugUnitTest --tests "*QuranForwarderActivityTest*"

How I ran into it

I link into the app from outside, with the parameters proposed in quran/quran-ios#1033. A link carrying any of them hits this before a single parameter is read, so the workaround today is a trailing slash — quran://2/255/?play=true — which happens to split cleanly.

@BiskremMuhammad BiskremMuhammad changed the title Keep the ayah when a quran:// link has a query string fix: keep the ayah when a quran:// link has a query string Nov 28, 2026
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.

1 participant

0