src/react/puppeteer/src/js/views/add-device-modal/ModalView.js
/**
   * Triggered whenever the hostname field is updated.
   * Checks whether the typed hostname is a valid http
   * or https url.
   */
Triggered whenever the hostname field is updated.
Checks whether the typed hostname is a valid http
or https url.
Triggered whenever the hostname field is updated . Checks whether the typed hostname is a valid http or https url .
handleUpdateHost(e) {
    const string = e.target.value.toString().trim();
    const regex = new RegExp(/https?:\/\/(www\.)?(([-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b)|localhost)([-a-zA-Z0-9@:%_+.~#?&\/=]*)/);
    if(string.match(regex)) {
      this.setState({
        host: string,
        validHost: true
      });
    }
    else if(!string.match(regex)) {
      this.setState({
        host: '',
        validHost: false
      });
    }
  }
handleUpdateHost ( e ) { const string = e . target . value . toString ( ) . trim ( ) ; const regex = new RegExp ( / https?:\/\/(www\.)?(([-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b)|localhost)([-a-zA-Z0-9@:%_+.~#?&\/=]*) / ) ; if ( string . match ( regex ) ) { this . setState ( { host : string , validHost : true } ) ; } else if ( ! string . match ( regex ) ) { this . setState ( { host : '' , validHost : false } ) ; } }
Triggered whenever the hostname field is updated.
Triggered whenever the hostname field is updated .