master
km0 3 years ago
parent 0f823c7237
commit 8de5337098

@ -11,7 +11,7 @@
<label for="text">Input: </label> <label for="text">Input: </label>
<input type="text" id="text" autofocus /> <input type="text" id="text" autofocus />
</form> </form>
<script> <script defer>
const log = (text, color) => { const log = (text, color) => {
document.getElementById( document.getElementById(
"log" "log"
@ -20,12 +20,10 @@
console.log(location.protocol); console.log(location.protocol);
console.log( console.log(
location.protocol == "https:" (location.protocol == "https:" ? "wss://" : "ws://") +
? "wss://" location.host +
: "ws://" + location.pathname.replace(new RegExp("\/" + "$"), "") +
location.host + "/echo/"
location.pathname.replace(new RegExp("\/" + "$"), "") +
"/echo/"
); );
const socket = new WebSocket( const socket = new WebSocket(

Loading…
Cancel
Save