MCPcopy
hub / github.com/robtaussig/react-use-websocket / appendQueryParams

Function appendQueryParams

src/lib/socket-io.ts:23–32  ·  view source on GitHub ↗
(url: string, params: QueryParams = {})

Source from the content-addressed store, hash-verified

21};
22
23export const appendQueryParams = (url: string, params: QueryParams = {}): string => {
24 const hasParamsRegex = /\?([\w]+=[\w]+)/;
25 const alreadyHasParams = hasParamsRegex.test(url);
26
27 const stringified = `${Object.entries(params).reduce((next, [key, value]) => {
28 return next + `${key}=${value}&`;
29 }, '').slice(0, -1)}`;
30
31 return `${url}${alreadyHasParams ? '&' : '?'}${stringified}`;
32};
33
34export const setUpSocketIOPing = (sendMessage: SendMessage, interval = SOCKET_IO_PING_INTERVAL): any => {
35 const ping = () => sendMessage(SOCKET_IO_PING_CODE);

Callers 2

socket-io.test.tsFile · 0.90
getUrlFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…