diff --git a/src/ids-host.test.ts b/src/ids-host.test.ts index 639b560..4c5e95c 100644 --- a/src/ids-host.test.ts +++ b/src/ids-host.test.ts @@ -1,7 +1,6 @@ import { IdsHost, discoverServicesStub, - mungeDiagnosticEndpoint, orderRecordsByPriorityWeight, recordToUrl, weightedRandom, @@ -145,60 +144,6 @@ describe("getDiagnosticsUrl", () => { } }); -describe("mungeDiagnosticEndpoint", () => { - type TestCase = { - description: string; - inputUrl: string; - defaultHost: string; - effectiveHost: string; - expectedUrl: string; - }; - - const testCases: TestCase[] = [ - { - description: - "The input URL is taken as the literal value if the IDS host isn't overridden", - inputUrl: "https://foo.com/bar", - defaultHost: "https://default", - effectiveHost: "https://default", - expectedUrl: "https://foo.com/bar", - }, - { - description: - "The input URL is taken as the literal value if the input URL's origin is pointed elsewhere", - inputUrl: "https://foo.com/bar", - defaultHost: "https://default", - effectiveHost: "https://someOtherHost", - expectedUrl: "https://foo.com/bar", - }, - { - description: - "The overridden IDS host is used as the base of the diagnostic endpoint, with the inputUrl smushed on top of it", - inputUrl: "https://default/bar", - defaultHost: "https://default", - effectiveHost: "ftp://user:password@someOtherHost:1234", - expectedUrl: "ftp://user:password@someOtherHost:1234/bar", - }, - ]; - - for (const { - description, - inputUrl, - defaultHost, - effectiveHost, - expectedUrl, - } of testCases) { - test(description, async () => { - const ret = await mungeDiagnosticEndpoint( - new URL(inputUrl), - new URL(defaultHost), - new URL(effectiveHost), - ); - expect(ret).toStrictEqual(new URL(expectedUrl)); - }); - } -}); - describe("recordToUrl", () => { test("a valid record", () => { expect( diff --git a/src/ids-host.ts b/src/ids-host.ts index 068ca7c..3e8e784 100644 --- a/src/ids-host.ts +++ b/src/ids-host.ts @@ -127,27 +127,6 @@ export class IdsHost { } } -export function mungeDiagnosticEndpoint( - inputUrl: URL, - defaultIdsHost: URL, - selectedIdsHost: URL, -): URL { - if (defaultIdsHost === selectedIdsHost) { - return inputUrl; - } - - if (inputUrl.origin !== defaultIdsHost.origin) { - return inputUrl; - } - - inputUrl.protocol = selectedIdsHost.protocol; - inputUrl.host = selectedIdsHost.host; - inputUrl.username = selectedIdsHost.username; - inputUrl.password = selectedIdsHost.password; - - return inputUrl; -} - export function recordToUrl(record: SrvRecord): URL | undefined { const urlStr = `https://${record.name}:${record.port}`; try {