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

(core) - Strip whitespace from query for GET requests #908

Merged
merged 3 commits into from
Jul 21, 2020
Merged

Conversation

JoviDeCroock
Copy link
Collaborator

@JoviDeCroock JoviDeCroock commented Jul 16, 2020

Summary

Strips redundant whitespaces when using GET

This solves the case where the user provides their own queries, ....

Fixes: #907

Set of changes

  • Strips redundant whitespaces when using GET

@changeset-bot
Copy link

changeset-bot bot commented Jul 16, 2020

🦋 Changeset is good to go

Latest commit: 538ffe2

We got this.

This PR includes changesets to release 1 package
Name Type
@urql/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JoviDeCroock JoviDeCroock requested a review from kitten July 17, 2020 09:58
@@ -49,7 +49,9 @@ export const makeFetchURL = (
}

if (body.query) {
search.push('query=' + encodeURIComponent(body.query));
search.push(
'query=' + encodeURIComponent(body.query.replace(/[\s,]+/g, ' ').trim())
Copy link
Contributor

Choose a reason for hiding this comment

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

How come we replace with a space? Also is it risky to remove commas?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The Graphql Query spec only needs the text to be seperated so we go for the smallest amount of space possible (commas aren't enforced)

@kitten kitten changed the title strip whistespace from query (core) - Strip whitespace from query for GET requests Jul 21, 2020
@kitten kitten merged commit b609ce0 into main Jul 21, 2020
@kitten kitten deleted the strip-whitespace branch July 21, 2020 21:30
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.

RFC: Reduce whitespace in queries by using stripIgnoredCharacters
3 participants