Skip to content

fix: correctly parse and route absolute anchor URLs in Interactive Book#557

Open
RAJEEVTIWARI8052 wants to merge 3 commits intoCircuitVerse:masterfrom
RAJEEVTIWARI8052:fix/frontend-ib-anchor-links
Open

fix: correctly parse and route absolute anchor URLs in Interactive Book#557
RAJEEVTIWARI8052 wants to merge 3 commits intoCircuitVerse:masterfrom
RAJEEVTIWARI8052:fix/frontend-ib-anchor-links

Conversation

@RAJEEVTIWARI8052
Copy link
Copy Markdown

@RAJEEVTIWARI8052 RAJEEVTIWARI8052 commented Mar 24, 2026

Fixes #556

###changes made in this PR:

  • Replaced the string-based prefix comparison logic (startsWith) with robust Uri parsing and path normalization in lib/ui/views/ib/ib_page_view.dart.
  • Accurately implemented Uri.decodeComponent extraction for internal Markdown anchor fragments (#) instead of incorrectly truncating the absolute URL string (href.substring(1)).
  • Prevented double-launching and unhandled external navigation of URLs by appropriately using isSameDocument checks and explicitly returning out of the logic blocks to satisfy static analysis and automated PR bot feedback.

Why these changes were necessary:

The previous Interactive Book routing logic incorrectly assumed that any absolute URL corresponding to the current document could simply have its first character stripped (href.substring(1)). This meant any internal same-page anchor link would be resolved to an invalid slug (e.g., ttps://learn.circuitverse...) and fail to scroll. Furthermore, the startsWith logic suffered from prefix fallback errors (where /chapter-1 could incorrectly flag /chapter-10 as a self-link). By parsing the exact URI schemes, paths, and fragment identifiers, all Interactive Book navigation correctly scopes and scrolls precisely to specific headings.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 24, 2026

Deploy Preview for cv-mobile-app-web ready!

Name Link
🔨 Latest commit d88eaa5
🔍 Latest deploy log https://app.netlify.com/projects/cv-mobile-app-web/deploys/69c2b93b04d60e000811460d
😎 Deploy Preview https://deploy-preview-557--cv-mobile-app-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

Walkthrough

The change updates _onTapLink to parse both the current page URL and the tapped href as Uri, normalizing trailing slashes, and to distinguish same-document anchor navigation from other IB base-URL links. It adds a direct equality guard (href == _model.pageData!.pageUrl) to no-op, decodes non-empty fragments and scrolls to matching anchors when scheme/host/path match, and preserves scrolling for href values starting with #. The prior startsWith-based base-URL scroll fallback and its substring-based scrolling behavior were removed; non-matching base-URL taps call launchURL(href).

Suggested labels

potential-ai-slop

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change in the pull request, which involves fixing the parsing and routing of anchor URLs in the Interactive Book feature by updating the _onTapLink method.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9076a730-1c36-4432-b8c5-fb22bf25023e

📥 Commits

Reviewing files that changed from the base of the PR and between f621531 and 431048b.

📒 Files selected for processing (1)
  • lib/ui/views/ib/ib_page_view.dart

Comment thread lib/ui/views/ib/ib_page_view.dart Outdated
Copy link
Copy Markdown
Author

@RAJEEVTIWARI8052 RAJEEVTIWARI8052 left a comment

Choose a reason for hiding this comment

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

i have resolved the issue raised

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fedeb22d-dfe5-49e0-bcd8-5e219816b655

📥 Commits

Reviewing files that changed from the base of the PR and between 431048b and a99dae0.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • lib/ui/views/ib/ib_page_view.dart
  • pubspec.yaml
✅ Files skipped from review due to trivial changes (1)
  • pubspec.yaml

Comment thread lib/ui/views/ib/ib_page_view.dart
@RAJEEVTIWARI8052
Copy link
Copy Markdown
Author

RAJEEVTIWARI8052 commented Mar 24, 2026

Hey @JatsuAkaYashvant I have pushed the fixes for this issue. Could you please take a look when you have a free moment? Thanks!

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]: Frontend Interactive Book incorrectly parses absolute anchor link URLs

1 participant