Procházet zdrojové kódy

Validate endpoint's provider name

Sergiu Miclea před 6 roky
rodič
revize
55b1d319c2

+ 3 - 3
src/components/organisms/ChooseProvider/ChooseProvider.jsx

@@ -151,13 +151,13 @@ class ChooseProvider extends React.Component<Props, State> {
     }
     }
     try {
     try {
       let endpoint: Endpoint = JSON.parse(content)
       let endpoint: Endpoint = JSON.parse(content)
-      if (!endpoint.name || !endpoint.type) {
-        throw new Error('Invalid endpoint')
+      if (!endpoint.name || !endpoint.type || !this.props.providers.find(p => p === endpoint.type)) {
+        throw new Error()
       }
       }
       delete endpoint.id
       delete endpoint.id
       this.chooseEndpoint(endpoint)
       this.chooseEndpoint(endpoint)
     } catch (err) {
     } catch (err) {
-      notificationStore.alert('The endpoint could not be parsed', 'error')
+      notificationStore.alert('Invalid .endpoint file', 'error')
     }
     }
   }
   }