OXYGENHUB
# f532c4266f21 oxygen-vscode / test / handoff.test.mjs
1.2 KiB · last changed Resolve in VS Code: open a conflict from OxygenHub 1 month ago source blame history raw
1
import { test } from "node:test";
2
import assert from "node:assert/strict";
3
import { parseResolveQuery, sameRemote } from "../out/handoff.mjs";
4
5
test("resolve links are read and checked", () => {
6
  const q = new URLSearchParams({ url: "https://hub.example:7343/andy/demo", bookmark: "feature/x", path: "src/a.txt" }).toString();
7
  assert.deepEqual(parseResolveQuery(q), { url: "https://hub.example:7343/andy/demo", bookmark: "feature/x", path: "src/a.txt" });
8
  assert.match(parseResolveQuery("bookmark=main&path=a"), /no repository URL/);
9
  assert.match(parseResolveQuery("url=https://h/r&bookmark=a..b&path=a"), /no valid bookmark/);
10
  assert.match(parseResolveQuery("url=https://h/r&bookmark=main&path=../etc/passwd"), /no valid path/);
11
  assert.match(parseResolveQuery("url=https://h/r&bookmark=main&path=.oxy/config"), /no valid path/);
12
});
13
14
test("remotes match across a trailing slash and the host's case", () => {
15
  assert.ok(sameRemote("https://Hub.Example:7343/andy/demo/", "https://hub.example:7343/andy/demo"));
16
  assert.ok(!sameRemote("https://hub.example:7343/andy/demo", "https://hub.example:7343/andy/other"));
17
  assert.ok(!sameRemote("https://hub.example:7343/andy/demo", "http://hub.example:7343/andy/demo"));
18
});