Ver código fonte

Merge pull request #121 from ihavenoface5/ReadableMapNullCheck

Added null and path key check on addCompleteDownload method
Travis Nuttall 5 anos atrás
pai
commit
ebc320f167
Nenhuma conta vinculada ao e-mail do autor do commit

+ 5
- 0
android/src/main/java/com/RNFetchBlob/RNFetchBlob.java Ver arquivo

372
     @ReactMethod
372
     @ReactMethod
373
     public void addCompleteDownload (ReadableMap config, Promise promise) {
373
     public void addCompleteDownload (ReadableMap config, Promise promise) {
374
         DownloadManager dm = (DownloadManager) RCTContext.getSystemService(RCTContext.DOWNLOAD_SERVICE);
374
         DownloadManager dm = (DownloadManager) RCTContext.getSystemService(RCTContext.DOWNLOAD_SERVICE);
375
+        if (config == null || !config.hasKey("path"))
376
+        {
377
+            promise.reject("EINVAL", "RNFetchblob.addCompleteDownload config or path missing.");
378
+            return;
379
+        }
375
         String path = RNFetchBlobFS.normalizePath(config.getString("path"));
380
         String path = RNFetchBlobFS.normalizePath(config.getString("path"));
376
         if(path == null) {
381
         if(path == null) {
377
             promise.reject("EINVAL", "RNFetchblob.addCompleteDownload can not resolve URI:" + config.getString("path"));
382
             promise.reject("EINVAL", "RNFetchblob.addCompleteDownload can not resolve URI:" + config.getString("path"));