Skip to content

Instantly share code, notes, and snippets.

View maxant's full-sized avatar

Ant Kutschera maxant

View GitHub Profile
@Paradoxis
Paradoxis / http-to-ws.js
Last active May 13, 2024 16:37
Convert WS/HTTP links with JavaScript
/**
* Converts an HTTP(S) url to a WS(S) URL
* Example:
* httpUrlToWebSockeUrl("http://www.example.com/") -> ws://www.example.com/
* httpUrlToWebSockeUrl("https://www.example.com/") -> wss://www.example.com/
*
* @param {string} url
* @return {string}
*/
function httpUrlToWebSockeUrl(url)