Skip to content

fix: keep hyperlink URL when it has a fragment - #1139

Open
nkuprins wants to merge 2 commits into
apache:mainfrom
nkuprins:fix/hyperlink-url-fragment
Open

nkuprins wants to merge 2 commits into
apache:mainfrom
nkuprins:fix/hyperlink-url-fragment

Conversation

@nkuprins

Copy link
Copy Markdown
Contributor

Closed: #1138

Purpose of the pull request

As title.

What's changed?

  • HyperlinkTagHandler resolves the r:id relationship first and appends "#" + location when both are present.
  • The two cases in the handler swap order (the r:id lookup is now case 1), and the Optional chain becomes a plain if, so the diff is larger than the change in behaviour.
  • New test ExtraDataTest#readHyperlinkWithUrlFragment reads extra/extraHyperlinkFragment.xlsx

Checklist

  • I have read the Contributor Guide.
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

@skytin1004 skytin1004 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix. I reproduced the issue on main and confirmed that this change preserves the full hyperlink, including the fragment. I also verified that internal links and external links without fragments still work as expected. The relevant tests passed locally on Java 11. LGTM.

This branch has not been deployed

No deployments
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] Hyperlink with a # part is read back without its target

2 participants