@robinnorth Is there any reason not to build the querystring for both GET and POST in 1 step, and then depending on the method, append it to location or the body?
@robinnorth Is there any reason not to build the querystring for both GET and POST in 1 step, and then depending on the method, append it to `location` or the body?
There was indeed a reason to build them separately to begin with, as I was updating the query string parameters for GET submissions, however I've had to abandon that and discard any previously-set ones in order to properly reflect the behaviour of unchecked checkbox inputs on form submission -- they should be omitted entirely from the query string, even if they had been checked previously.
So, I will refactor this as suggested.
There was indeed a reason to build them separately to begin with, as I was updating the query string parameters for GET submissions, however I've had to abandon that and discard any previously-set ones in order to properly reflect the behaviour of unchecked checkbox inputs on form submission -- they should be omitted entirely from the query string, even if they had been checked previously.
So, I will refactor this as suggested.
Technically maybe, but as we don't document the requestOptions option or its keys, so the implication could be that you shouldn't rely on it to have a certain shape. I'm not sure that it's actually very useful to have requestOptions be a part of this.options anyway, as it's only intended to be set internally by the library. As #127 and #130 show, it just causes issues with manual invocation when it's not set. Perhaps it should be refactored to this.requestOptions?
Technically maybe, but as we don't document the `requestOptions` option or its keys, so the implication could be that you shouldn't rely on it to have a certain shape. I'm not sure that it's actually very useful to have `requestOptions` be a part of `this.options` anyway, as it's only intended to be set internally by the library. As #127 and #130 show, it just causes issues with manual invocation when it's not set. Perhaps it should be refactored to `this.requestOptions`?
No, I don't think we do need it to be global -- it can just be a third parameter to loadUrl(), after options, and default to an empty object if not set.
No, I don't think we do need it to be global -- it can just be a third parameter to `loadUrl()`, after `options`, and default to an empty object if not set.
Currently the history popstate handler relies on being able to pass a modified options object to loadUrl, so I don't think we can easily drop that parameter.
Currently the history popstate handler relies on being able to pass a modified options object to `loadUrl`, so I don't think we can easily drop that parameter.
@BehindTheMath I have pushed a refactor commit for the query string building, but have left requestOptions as-is for now, as I intend to make a separate PR to make some changes around that. Would be good to merge this before submitting that too.
@BehindTheMath I have pushed a refactor commit for the query string building, but have left `requestOptions` as-is for now, as I intend to make a separate PR to make some changes around that. Would be good to merge this before submitting that too.
After thinking more about requestOptions, do we need it to be in this.options so that it gets stored with the history?
Looks good, so you can squash and merge this.
After thinking more about `requestOptions`, do we need it to be in `this.options` so that it gets stored with the history?
Yes, I came to the same conclusion as you about requestOptions after stepping through the code, but am going to change it so that lib/send-request.js handles requestOptions being empty without throwing an error.
Thanks @BehindTheMath.
Yes, I came to the same conclusion as you about `requestOptions` after stepping through the code, but am going to change it so that `lib/send-request.js` handles `requestOptions` being empty without throwing an error.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes check for radio and checkbox inputs (#124) and GET form submission (#126)
@robinnorth Is there any reason not to build the querystring for both GET and POST in 1 step, and then depending on the method, append it to
locationor the body?@robinnorth Would this be considered a breaking change?
There was indeed a reason to build them separately to begin with, as I was updating the query string parameters for GET submissions, however I've had to abandon that and discard any previously-set ones in order to properly reflect the behaviour of unchecked checkbox inputs on form submission -- they should be omitted entirely from the query string, even if they had been checked previously.
So, I will refactor this as suggested.
Technically maybe, but as we don't document the
requestOptionsoption or its keys, so the implication could be that you shouldn't rely on it to have a certain shape. I'm not sure that it's actually very useful to haverequestOptionsbe a part ofthis.optionsanyway, as it's only intended to be set internally by the library. As #127 and #130 show, it just causes issues with manual invocation when it's not set. Perhaps it should be refactored tothis.requestOptions?Do we need a global
requestOptionsat all? Why don't we just pass it directly toloadUrl()?No, I don't think we do need it to be global -- it can just be a third parameter to
loadUrl(), afteroptions, and default to an empty object if not set.That would be simpler.
I don't think we need to pass
optionseither. When it's needed, it can be retrieved fromthis.options.Currently the history popstate handler relies on being able to pass a modified options object to
loadUrl, so I don't think we can easily drop that parameter.Good point. But if it's not passed in, we can default to
this.options.@BehindTheMath I have pushed a refactor commit for the query string building, but have left
requestOptionsas-is for now, as I intend to make a separate PR to make some changes around that. Would be good to merge this before submitting that too.Looks good, so you can squash and merge this.
After thinking more about
requestOptions, do we need it to be inthis.optionsso that it gets stored with the history?Thanks @BehindTheMath.
Yes, I came to the same conclusion as you about
requestOptionsafter stepping through the code, but am going to change it so thatlib/send-request.jshandlesrequestOptionsbeing empty without throwing an error.