Skip to content

fix(PdfViewer): do not render when url is empty#508

Merged
ArgoZhang merged 2 commits intomasterfrom
fix-viewer
Aug 1, 2025
Merged

fix(PdfViewer): do not render when url is empty#508
ArgoZhang merged 2 commits intomasterfrom
fix-viewer

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Aug 1, 2025

Link issues

fixes #507

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Prevent the PdfViewer from rendering an invalid URL by returning an empty string for empty inputs and consistently appending the page index to the absolute URI.

Bug Fixes:

  • Return an empty string from GetAbsoluteUri when the URL is empty instead of rendering a broken link
  • Always append the page index to the resolved absolute URI and remove the UseGoogleDocs check

@bb-auto bb-auto Bot added the bug Something isn't working label Aug 1, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Aug 1, 2025

Reviewer's Guide

Refine PdfViewer.GetAbsoluteUri implementation to skip rendering for empty URLs and consolidate page parameter logic when constructing PDF URLs.

Class diagram for updated PdfViewer.GetAbsoluteUri method

classDiagram
    class PdfViewer {
        +string GetAbsoluteUri(string? url)
    }

    PdfViewer : GetAbsoluteUri now returns string.Empty if url is null or empty
    PdfViewer : GetAbsoluteUri appends #page={PageIndex} only if url is not empty
Loading

File-Level Changes

Change Details Files
Prevent rendering PDF viewer when URL is empty and consolidate page parameter handling
  • Return empty string immediately if the URL is null or empty
  • Remove UseGoogleDocs check to always apply logic for valid URLs
  • Move '#page={PageIndex}' append into the non-empty URL branch after generating absolute URI
src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#507 Prevent the PdfViewer component from rendering when the URL is empty.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto Bot added this to the v9.2.0 milestone Aug 1, 2025
@ArgoZhang ArgoZhang merged commit 85171ca into master Aug 1, 2025
1 check passed
@ArgoZhang ArgoZhang deleted the fix-viewer branch August 1, 2025 02:10
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @ArgoZhang - I've reviewed your changes - here's some feedback:

  • Double-check that removing the UseGoogleDocs branch matches the desired behavior—if you still need a fallback when UseGoogleDocs is false you should re-introduce that condition or handle it elsewhere.
  • Make sure that returning an empty string from GetAbsoluteUri reliably prevents the viewer from rendering in your Razor markup so you don’t end up with a blank placeholder.
  • Consider how appending "#page={PageIndex}" interacts with URLs that already include query strings or fragments to avoid generating malformed URIs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Double-check that removing the UseGoogleDocs branch matches the desired behavior—if you still need a fallback when UseGoogleDocs is false you should re-introduce that condition or handle it elsewhere.
- Make sure that returning an empty string from GetAbsoluteUri reliably prevents the viewer from rendering in your Razor markup so you don’t end up with a blank placeholder.
- Consider how appending "#page={PageIndex}" interacts with URLs that already include query strings or fragments to avoid generating malformed URIs.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(PdfViewer): do not render when url is empty

1 participant