Explorar o código

Merge pull request #681 from transloadit/improvement/url

Check url in URL plugin
Artur Paikin %!s(int64=7) %!d(string=hai) anos
pai
achega
f04b664cfa
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      src/plugins/Url/index.js

+ 8 - 1
src/plugins/Url/index.js

@@ -29,7 +29,8 @@ module.exports = class Url extends Plugin {
         addUrl: 'Add url',
         addUrl: 'Add url',
         import: 'Import',
         import: 'Import',
         enterUrlToImport: 'Enter file url to import',
         enterUrlToImport: 'Enter file url to import',
-        failedToFetch: 'Uppy Server failed to fetch this URL'
+        failedToFetch: 'Uppy Server failed to fetch this URL, please make sure it’s correct',
+        enterCorrectUrl: 'Please enter correct URL to add file'
       }
       }
     }
     }
 
 
@@ -83,6 +84,12 @@ module.exports = class Url extends Plugin {
   }
   }
 
 
   addFile (url) {
   addFile (url) {
+    if (!url) {
+      this.uppy.log('[URL] Incorrect URL entered')
+      this.uppy.info(this.i18n('enterCorrectUrl'), 'error', 4000)
+      return
+    }
+
     return this.getMeta(url).then((meta) => {
     return this.getMeta(url).then((meta) => {
       const tagFile = {
       const tagFile = {
         source: this.id,
         source: this.id,