-
-
Notifications
You must be signed in to change notification settings - Fork 598
Using serverUrl constant for batch requests. #153
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
Current coverage is
|
Importing |
@andrewimm I could take strip out the parsing pieces for the path rather than use the module if you concerned about bloat. |
// Remove the protocol
var url = serverUrl.replace(/https?:\/\//, '');
var path = url.substr(url.indexOf('/')); should work, right? |
That'll work for the current |
And what would those cases be? This works for urls with and without protocol. In a valid URL, slashes can only exist between the protocol and the domain, or within the path, so once the protocol is removed, the first slash is the beginning of the path. Beyond that, setting an invalid value to this will break the entire SDK anyways, so it's not unreasonable to us to say that only valid URLs are supported. |
Actually, we need the "does it end with a slash?" check to make it really work. Otherwise a value like "api.parse.com" fails. Otherwise, I think it's relatively bulletproof. |
We'll need to handle the host case as well: |
@peterdotjs the code works for that: var url = 'https://localhost.com:8080/p/a/t/h'.replace(/https?:\/\//, ''); // url = localhost.com:8080/p/a/t/h
var path = url.substr(url.indexOf('/')); // path = '/p/a/t/h' Feel free to unit-test this thing into oblivion |
My only concern is adding a 650 LOC library to do something that can be done in 1-2 lines. |
@andrewimm agreed that there are a lot of things in the lib we won't use. I'm sure there will be other cases that come up ( |
For now, treat it as a private API (it's not like anyone could have their own Parse address anyways, this is basically for our internal tests for now). If we ever publicize it, we can establish expectations and shore up the code, but immediately, I like treating it like a black box. |
Also, once you land this change, I'd like to cut a release for 1.6.14, which will probably be the last one before 1.7 |
3db0fb6
to
83e0470
Compare
Ready for merging. |
LGTM, merging. |
Using serverUrl constant for batch requests.
No description provided.