Skip to content
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

Fix query string bugs relating to repeated elements #79

Merged
merged 1 commit into from
Jan 31, 2020

Conversation

jon-betts
Copy link
Contributor

  • Also separate out testing of the component
  • Remove duplicated testing in other places
  • Use the same code more times
    • Rather than inventing a new way at the end of get_content_type()

(
"/https://example.com/foo?via.open_sidebar=1",
"http://via.hypothes.is/https://example.com/foo?via.open_sidebar=1",
"text/html",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these tests amount to the same thing, and are replicated lower down. We always pass all params onto the final request. It only changes when we call the original URL to check the resource content type.

"h_open_sidebar": asbool(request.params.get(OPEN_SIDEBAR, False)),
"h_request_config": request.params.get(CONFIG_FROM_FRAME, None),
"h_open_sidebar": asbool(request.params.get(QueryParams.OPEN_SIDEBAR, False)),
"h_request_config": request.params.get(QueryParams.CONFIG_FROM_FRAME, None),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This bit of processing could be moved to QueryParams, but then:

  • This code wouldn't have anything to do and would get sad
  • The code wouldn't get any shorter as we'd have to unpack whatever we were sent

via/views/_query_params.py Outdated Show resolved Hide resolved
@jon-betts jon-betts removed the wip label Jan 29, 2020
@jon-betts jon-betts requested a review from seanh January 29, 2020 18:24
via/views/_query_params.py Outdated Show resolved Hide resolved
via/views/_query_params.py Show resolved Hide resolved
tests/unit/via/views/test_route_by_content.py Outdated Show resolved Hide resolved
via/views/route_by_content.py Show resolved Hide resolved
via/views/route_by_content.py Show resolved Hide resolved
return exc.HTTPFound(f"{via_url}/{url}", headers=headers)
return exc.HTTPFound(
QueryParams.build_url(
f"{via_url}/{path_url}", request.params, strip_via_params=False
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f"{via_url}/{path_url}", request.params, strip_via_params=False
f"{via_url}/{path_url}", request.params

It defaults to False

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think I might remove the default to force you to say. This was to make crystal clear the intent.

 * Also separate out testing of the component
 * Remove duplicated testing in other places
 * Use the same code more times
   * Rather than inventing a new way at the end of get_content_type()
@jon-betts jon-betts force-pushed the query-params-improvements branch from edd94af to 487966c Compare January 30, 2020 16:46
@jon-betts jon-betts changed the title Fix query string bugs relating to repeated elements and case Fix query string bugs relating to repeated elements Jan 31, 2020
@jon-betts
Copy link
Contributor Author

So after some more research it turns out that the query parameters are case sensitive. I've changed the PR to reflect that and the review points above.

@jon-betts jon-betts merged commit 8b8078e into master Jan 31, 2020
@jon-betts jon-betts deleted the query-params-improvements branch January 31, 2020 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants