Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 837ddf2

Browse files
committed
Iterate
Signed-off-by: Michael Telatynski <[email protected]>
1 parent fc4866f commit 837ddf2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/SlidingSyncManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export class SlidingSyncManager {
401401

402402
const proxyUrl = await this.getProxyFromWellKnown(client);
403403
if (proxyUrl != undefined) {
404-
const response = await fetch(proxyUrl + "/client/server.json", {
404+
const response = await fetch(new URL("/client/server.json", proxyUrl), {
405405
method: Method.Get,
406406
signal: timeoutSignal(10 * 1000), // 10s
407407
});

test/SlidingSyncManager-test.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ describe("SlidingSyncManager", () => {
4040
mocked(client.getRoom).mockReturnValue(null);
4141
manager.configure(client, "invalid");
4242
manager.slidingSync = slidingSync;
43+
fetchMockJest.reset();
44+
fetchMockJest.get("https://proxy/client/server.json", {});
4345
});
4446

4547
describe("setRoomVisible", () => {
@@ -237,7 +239,7 @@ describe("SlidingSyncManager", () => {
237239
describe("checkSupport", () => {
238240
beforeEach(() => {
239241
SlidingSyncController.serverSupportsSlidingSync = false;
240-
jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("proxy");
242+
jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("https://proxy/");
241243
});
242244
it("shorts out if the server has 'native' sliding sync support", async () => {
243245
jest.spyOn(manager, "nativeSlidingSyncSupport").mockResolvedValue(true);
@@ -260,7 +262,7 @@ describe("SlidingSyncManager", () => {
260262
server: "matrix.org",
261263
},
262264
"org.matrix.msc3575.proxy": {
263-
url: "proxy",
265+
url: "https://proxy/",
264266
},
265267
});
266268
fetchMockJest.get("https://matrix-client.matrix.org/_matrix/client/versions", { versions: ["v1.4"] });
@@ -286,7 +288,7 @@ describe("SlidingSyncManager", () => {
286288
expect(feature).toBe("org.matrix.msc3575");
287289
return true;
288290
});
289-
const proxySpy = jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("proxy");
291+
const proxySpy = jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("https://proxy/");
290292

291293
expect(SlidingSyncController.serverSupportsSlidingSync).toBeFalsy();
292294
await manager.checkSupport(client); // first thing it does is call nativeSlidingSyncSupport
@@ -307,14 +309,14 @@ describe("SlidingSyncManager", () => {
307309
expect(manager.startSpidering).toHaveBeenCalled();
308310
});
309311
it("uses the proxy declared in the client well-known", async () => {
310-
jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("proxy");
312+
jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("https://proxy/");
311313
await manager.setup(client);
312314
expect(manager.configure).toHaveBeenCalled();
313-
expect(manager.configure).toHaveBeenCalledWith(client, "proxy");
315+
expect(manager.configure).toHaveBeenCalledWith(client, "https://proxy/");
314316
expect(manager.startSpidering).toHaveBeenCalled();
315317
});
316318
it("uses the legacy `feature_sliding_sync_proxy_url` if it was set", async () => {
317-
jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("proxy");
319+
jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("https://proxy/");
318320
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => {
319321
if (name === "feature_sliding_sync_proxy_url") return "legacy-proxy";
320322
});

0 commit comments

Comments
 (0)