Skip to content

Fix addQueryArgs and removeQueryArg on URLs with fragments #69313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2025

Conversation

davilera
Copy link
Contributor

Description

Fixes #16655 (query args should be added before a fragment and not after). It also fixes:

  • removeQueryArgs should not remove the url fragment
  • removeQueryArgs should not remove what looks like a query arg after url fragment

How has this been tested?

I’ve added new tests in @wordpress/url package that reproduce the issues aforementioned. Then, I've modified addQueryArgs and removeQueryArgs to pass those tests. In both instances, the approach is basically the same:

  1. Remove the fragment from the URL
  2. Operate as normal
  3. Re-append the fragment

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.

Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: davilera <davilera@git.wordpress.org>
Co-authored-by: paaljoachim <paaljoachim@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Url /packages/url labels Feb 26, 2025
@Mamaduka Mamaduka merged commit 7a4b5aa into WordPress:trunk Feb 26, 2025
66 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.4 milestone Feb 26, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…Press#69313)

Co-authored-by: davilera <davilera@git.wordpress.org>
Co-authored-by: paaljoachim <paaljoachim@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Url /packages/url [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function addQueryArgs in @wordpress/url should add query args before URL fragment
4 participants