-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Properly handle serverURL and publicServerUrl in Batch requests #6980 #7049
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
Conversation
884d5a4
to
70e0105
Compare
Codecov Report
@@ Coverage Diff @@
## master #7049 +/- ##
==========================================
- Coverage 93.86% 93.84% -0.03%
==========================================
Files 169 169
Lines 12437 12440 +3
==========================================
Hits 11674 11674
- Misses 763 766 +3
Continue to review full report at Codecov.
|
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.
Just a quick nit. Looks good to me.
const startsWithPublic = requestPath.startsWith(publicPath); | ||
const pathLengthToUse = | ||
startsWithLocal && startsWithPublic | ||
? Math.max(localPath.length, publicPath.length) |
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.
It took me a second to figure out what this was doing. Good way to tell which one "startsWith" more.
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.
Sorry about this... I wrote this four times trying to find a clear way to do it and am still unhappy with the readability... definitely open to suggestions on strategy or clarity here!
src/batch.js
Outdated
? Math.max(localPath.length, publicPath.length) | ||
: startsWithLocal | ||
? localPath.length | ||
: publicPath.length; | ||
// Build the new path by removing the public path | ||
// and joining with the local path |
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.
Can you remove this old comment?
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.
LGTM 🚀
…-community#6980 (parse-community#7049) * fix: detect if the caller is accessing us via local or parse for batch requests (parse-community#6980) * chore: minor cleanup from PR
…-community#6980 (parse-community#7049) * fix: detect if the caller is accessing us via local or parse for batch requests (parse-community#6980) * chore: minor cleanup from PR
…-community#6980 (parse-community#7049) * fix: detect if the caller is accessing us via local or parse for batch requests (parse-community#6980) * chore: minor cleanup from PR
See #6980 for more context
I'm not 100% confident I understand the intended distinction between
serverUrl
andpublicServerUrl
but my instinct is that on a production machine I should be able to access parse server via either URL. That seems to be the case for everything BUT batch requests which have an assumption that requests come only from the pubic URL. This patch has a rough-shod attempt at a quick-and-dirty detection of which kind of URL is being used to construct thenewPath
appropriately.The included test fails before the patch, passes afterwards.