Skip to content

wcurl: strip URL fragment identifier from output filename - #97

Merged
sergiodj merged 1 commit into
curl:mainfrom
arpitguptagithub:fix-fragment-stripping
May 1, 2026
Merged

wcurl: strip URL fragment identifier from output filename#97
sergiodj merged 1 commit into
curl:mainfrom
arpitguptagithub:fix-fragment-stripping

Conversation

@arpitguptagithub

Copy link
Copy Markdown
Contributor

This PR is for updatng get_url_filename() to strip URL fragments (#) identically to how it strips query strings (?).

Reason to do this is when someone try extracting a filename from a URL, wcurl currently strips everything after ?. however, if the URL contains a fragment.... (e.g. example.com/document.pdf#page=5), the filename is generated locally as ....document.pdf#page=5. According to RFC (Idk exact number did just AI to confirm) , the fragment identifier is client-side metadata and thus is not part of the physical file name or path.

This is fixed by changing the sed substitution to match [?#] instead of just ?, a small regex change.

Testing
Added testFragmentStripping to tests.sh to verify #fragments are correctly stripped from the output filename.

@sergiodj sergiodj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch, thanks!

@sergiodj
sergiodj merged commit 07ca8d1 into curl:main May 1, 2026
4 checks passed
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.

3 participants