-
-
Notifications
You must be signed in to change notification settings - Fork 458
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) - Shorten queries for hashing #911
Conversation
🦋 Changeset is good to goLatest commit: 9521137 We got this. This PR includes changesets to release 1 package
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 |
@@ -7,7 +7,8 @@ interface Documents { | |||
[key: number]: DocumentNode; | |||
} | |||
|
|||
const hashQuery = (q: string): number => hash(q.replace(/[\s,]+/g, ' ').trim()); | |||
const hashQuery = (q: string): number => | |||
hash(q.replace(/([\s,]|#[^\n\r]+)+/g, ' ').trim()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I wonder if we should confirm that hashes only ever occur after newline+whitespace (though I'm sure this should be okay)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wgolledge I've added a test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 😁
Summary
This shortens the querystring by removing whitespaces and comments when a request is created with an unparsed query.