Repository navigation
Conversation
There was a problem hiding this comment.
🟢 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A search or autocomplete query w/ a slash gets split across URL path segments. For example,
shirts/a?bis sent asshirts/a%3Fbinstead ofshirts%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.