[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [pluggable-transports/snowflake-webext] 01/06: Factor WS.makeWebsocketURL out of WS.makeWebsocket.
This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch main
in repository pluggable-transports/snowflake-webext.
commit 840ab4189531d2edf4705d757d286b32c26b046c
Author: David Fifield <david@xxxxxxxxxxxxxxx>
AuthorDate: Wed Mar 29 11:39:37 2023 -0600
Factor WS.makeWebsocketURL out of WS.makeWebsocket.
To permit testing without accessing the network.
---
websocket.js | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/websocket.js b/websocket.js
index 4b56756..b49bd2f 100644
--- a/websocket.js
+++ b/websocket.js
@@ -5,19 +5,28 @@ Only websocket-specific stuff.
// eslint-disable-next-line no-unused-vars
class WS {
/**
- * Creates a websocket connection from a URL and params to override
+ * Creates a websocket URL from a base URL and params to override
* @param {URL|string} url
* @param {URLSearchParams|string[][]} params
- * @return {WebSocket}
+ * @return {URL}
*/
- static makeWebsocket(url, params) {
+ static makeWebsocketURL(url, params) {
let parsedURL = new URL(url);
let urlpa = new URLSearchParams(params);
urlpa.forEach(function (value, key) {
parsedURL.searchParams.set(key, value);
});
+ return new URL(url);
+ }
- let ws = new WebSocket(url);
+ /**
+ * Creates a websocket connection from a URL and params to override
+ * @param {URL|string} url
+ * @param {URLSearchParams|string[][]} params
+ * @return {WebSocket}
+ */
+ static makeWebsocket(url, params) {
+ let ws = new WebSocket(WS.makeWebsocketURL(url, params));
/*
'User agents can use this as a hint for how to handle incoming binary data:
if the attribute is set to 'blob', it is safe to spool it to disk, and if it
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits