nativescript-community / https

Secure HTTP client with SSL pinning for Nativescript - iOS/Android
https://nativescript-community.github.io/https/
Other
51 stars 42 forks source link

iOS support for Arrays #50

Closed bobbyngwu closed 4 years ago

bobbyngwu commented 4 years ago

Hi Eddy,

In iOS, is there a good reason why the support for arrays was removed post 1.0.2

Version 1.0.2

let dict_1 = null;
            if (opts.body) {
                var cont_1 = opts.body;

** removed code

               if (Array.isArray(cont_1)) {
                    dict_1 = NSMutableArray.new();
                    cont_1.forEach(function (item, idx) {
                        dict_1.addObject(item);
                    });
                }

** eof removed code

                else if (types_1.isObject(cont_1)) {
                    dict_1 = NSMutableDictionary.new();
                    Object.keys(cont_1).forEach(function (key) {
                        dict_1.setValueForKey(cont_1[key], key);
                    });
                }
            }

Version 1.2.1

let dict: NSMutableDictionary<string, any> = null;
      if (opts.body) {
        let cont = opts.body;
        if (isObject(cont)) {
          dict = NSMutableDictionary.new<string, any>();
          Object.keys(cont).forEach(key => dict.setValueForKey(cont[key] as any, key));
        }
      }

Please let me know as this is holding back things here.

EddyVerbruggen commented 4 years ago

Hi, if you look at the history of that file you'll see I didn't remove it because I was not the owner/maintainer of this plugin at the time. So can't tell you.

bobbyngwu commented 4 years ago

Oh didn't realise that. Are you happy for me to put this back and create a pull request?

EddyVerbruggen commented 4 years ago

I sure am, but please check the history of that file and see if there's a comment about why it was changed.

bobbyngwu commented 4 years ago

I take it back, looking at the history, it was always objects that was supported. The implementation above was a fork from version 1.0.2 on a private repo. The lack of array objects may have influenced that. I will create a pull request once I am done with my investigation. Thanks

bobbyngwu commented 4 years ago

Hi, created a pull request for the above. Let me know if this is okay