From 703d03da3bf0b4952b5adad21cbd880866c9f984 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sat, 19 Sep 2020 17:14:06 -0600 Subject: [PATCH] Add error styling, and rename url to uri --- src/components/WebsocketURL.vue | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/components/WebsocketURL.vue b/src/components/WebsocketURL.vue index d24c54c..12d6653 100644 --- a/src/components/WebsocketURL.vue +++ b/src/components/WebsocketURL.vue @@ -10,12 +10,14 @@
@@ -27,14 +29,17 @@ export default { name: 'WebsocketEntry', components: {}, data() {return { - ws_url: ``, + ws_uri: ``, + has_error: false, + ws_regex: /^(wss?|https?):\/\//, }}, methods: { - submit_ws_url() { - if (this.ws_url.length > 0 && this.ws_url.match(/^wss?:\/\//)) { - this.$emit(`set-ws-url`, this.ws_url); + submit_ws_uri() { + if (this.ws_uri.length > 0 && this.ws_uri.match(this.ws_regex)) { + this.$emit(`try-ws-uri`, this.ws_uri); } else { - alert(`Invalid websocket URL, it must begin with "wss://" in order to connect.`) + this.has_error = true; + alert(`Invalid websocket URL, please check that you typed it correctly.`) } }, },