Skip to content

Escape slashes in search and autocomplete query paths - #110

Open
ItsM0rty wants to merge 1 commit into
Constructor-io:masterfrom
ItsM0rty:code-fix/escape-search-path-segments
Open

ItsM0rty wants to merge 1 commit into
Constructor-io:masterfrom
ItsM0rty:code-fix/escape-search-path-segments

Conversation

@ItsM0rty

Copy link
Copy Markdown

A search or autocomplete query w/ a slash gets split across URL path segments. For example, shirts/a?b is sent as shirts/a%3Fb instead of shirts%2Fa%3Fb.

This escapes the query as one path segment in both methods. I added mocked request tests for both; they fail on master and pass w/ the fix. The tests also check that the question mark stays encoded.

Fixes #109.

Tested: python -m pytest -q -o addopts='' tests/test_search_path_encoding.py (2 passed). The full suite needs Constructor test API credentials, so I couldn't run the live integration tests.

@ItsM0rty
ItsM0rty requested a review from a team as a code owner November 15, 2026 04:41
Copilot AI balanced review requested due to automatic review settings November 15, 2026 04:41

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.

🟢 Approval recommended

No active review issues are identified for the change that encodes search and autocomplete queries as single URL path segments.

No open issues 🎉

What changed in this PR

Fixes #109 by encoding search and autocomplete queries as single URL path segments, preventing slashes from changing request routing.

Changes:

  • Uses quote(query, safe="") in both URL builders to escape slashes.
  • Adds mocked regression tests for both public methods, verifying that slashes and question marks remain encoded.
File Description
tests/​test_search_path_encoding.py Adds parameterized URL-encoding tests for search and autocomplete.
constructor_io/​modules/​search.py Escapes slashes in search query paths.
constructor_io/​modules/​autocomplete.py Escapes slashes in autocomplete query paths.

Review effort: Balanced

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

2 participants