From fd5425659dafc88e1b9049dac6ea2a41b742ba77 Mon Sep 17 00:00:00 2001 From: Trek H Date: Tue, 28 Jan 2020 14:26:06 +1030 Subject: [PATCH] mjpeg-player: simplified main.js's load function --- cmd/mjpeg-player/main.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/cmd/mjpeg-player/main.js b/cmd/mjpeg-player/main.js index e4a0eba0..9f24b5d0 100644 --- a/cmd/mjpeg-player/main.js +++ b/cmd/mjpeg-player/main.js @@ -42,10 +42,10 @@ init(); function load() { let url = document.getElementById('url').value; if (url == "") { - url = getQuery() + // Get everything following the ? from the browser's URL bar. + url = window.location.search.slice(1); document.getElementById('url').value = url; - } - if (url[0] == '/') { + } else if (url[0] == '/') { url = window.location.protocol + '//' + window.location.host + url; } if (url == "") { @@ -56,17 +56,6 @@ function load() { hls.loadSource(url, append); } -// getQuery gets everything after the question mark from the URL in the browser's URL bar. -function getQuery() { - let regex = new RegExp("\\?(.*)"); - let match = regex.exec(window.location.href); - if (match == null) { - return ''; - } else { - return decodeURIComponent(match[1].replace(/\+/g, " ")); - } -} - // append, on the first call, starts a player worker and passes it a frame rate and the video data, // on subsequent calls it passes the video data to the player worker. function append(data) {