Skip to content

Fix plus decoding in URL search hashes#2695

Merged
simon04 merged 1 commit into
freeCodeCamp:mainfrom
puneetdixit200:fix-url-search-plus-hash
Jun 21, 2026
Merged

Fix plus decoding in URL search hashes#2695
simon04 merged 1 commit into
freeCodeCamp:mainfrom
puneetdixit200:fix-url-search-plus-hash

Conversation

@puneetdixit200

Copy link
Copy Markdown

Summary

  • add a hash-fragment decoder that preserves literal + characters
  • use it for URL search hash parsing in both Search and SearchScope
  • cover scoped C++ URL searches and encoded literal plus queries with a focused Node test

Fixes #2463.

Tests

  • node --test test/assets/search_hash_test.js
  • node --check assets/javascripts/lib/util.js && node --check assets/javascripts/views/search/search.js && node --check assets/javascripts/views/search/search_scope.js && node --check test/assets/search_hash_test.js
  • git diff --check

Not run locally: bundle exec rake because this checkout requires Ruby 4.0.5 and Bundler 4.0.12, while this machine only has system Ruby 2.6.10 and no matching Bundler.

@puneetdixit200 puneetdixit200 requested a review from a team as a code owner June 4, 2026 04:27
@simon04 simon04 requested a review from Copilot June 21, 2026 04:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes URL hash-based searches where literal + characters (e.g., c++) were incorrectly treated as spaces during decoding, which broke scoped searches like #q=c++%20std::min.

Changes:

  • Added $.urlDecodeFragment to decode hash fragments without converting + into spaces.
  • Updated Search and SearchScope hash parsing to use $.urlDecodeFragment.
  • Added a focused Node test covering scoped C++ URL searches and encoded literal plus queries.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
assets/javascripts/lib/util.js Adds $.urlDecodeFragment for fragment decoding that preserves literal +.
assets/javascripts/views/search/search.js Switches hash decoding to $.urlDecodeFragment when extracting the query.
assets/javascripts/views/search/search_scope.js Switches hash decoding to $.urlDecodeFragment for scoped hash extraction and rewrite.
test/assets/search_hash_test.js Adds a Node VM-based test covering the C++ scoped query regression and %2B literal plus decoding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@simon04 simon04 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.

Thank you!

@simon04 simon04 merged commit 5dab0ac into freeCodeCamp:main Jun 21, 2026
1 check 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.

Searching C++ doc by URL is broken

3 participants