Explorar el Código

Validate endpoint's provider name

Sergiu Miclea hace 6 años
padre
commit
55b1d319c2
Se han modificado 1 ficheros con 3 adiciones y 3 borrados
  1. 3 3
      src/components/organisms/ChooseProvider/ChooseProvider.jsx

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

@@ -151,13 +151,13 @@ class ChooseProvider extends React.Component<Props, State> {
     }
     try {
       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
       this.chooseEndpoint(endpoint)
     } catch (err) {
-      notificationStore.alert('The endpoint could not be parsed', 'error')
+      notificationStore.alert('Invalid .endpoint file', 'error')
     }
   }