Skip to content

Commit 150bba4

Browse files
committed
fix: send the host field based on the extension id
The typo caused Ghostbird to sending blank string for the `host` field.
1 parent 16e8e57 commit 150bba4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/ghosttext-adaptor/client_options_loader.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,30 @@ export class ClientOptionsLoader implements IClientOptionsLoader {
1111

1212
async load(): Promise<ClientOptions> {
1313
let { serverPort } = await this.storedOptionsLoader.load()
14+
const extensionId = this.manifestInfo.getId()
1415
let serverUrl = new URL(`http://localhost:${serverPort}/`)
15-
let { host } = new URL(`extension: //${this.manifestInfo.getId()}.localhost`)
16+
let { host } = new URL(`extension://${extensionId}.localhost`)
1617

1718
return {
1819
serverUrl,
1920
clientHostName: host,
2021
}
2122
}
2223
}
24+
25+
if (import.meta.vitest) {
26+
const { describe, expect, it, vi } = import.meta.vitest
27+
28+
describe(ClientOptionsLoader, () => {
29+
it("should build a ClientOption from storage and manifest info correctly", async () => {
30+
const storedOptionsLoader = { load: vi.fn().mockResolvedValue({ serverPort: 1234 }) }
31+
const manifestInfo = { getId: vi.fn().mockReturnValue("@test.extension") }
32+
const sut = new ClientOptionsLoader(storedOptionsLoader, manifestInfo)
33+
34+
await expect(sut.load()).resolves.deep.equals({
35+
serverUrl: new URL("http://localhost:1234/"),
36+
clientHostName: "test.extension.localhost",
37+
})
38+
})
39+
})
40+
}

0 commit comments

Comments
 (0)