Skip to content

Commit

Permalink
drop now unused mungeDiagnosticEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed May 31, 2024
1 parent 6595e45 commit 6cac4a7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 76 deletions.
55 changes: 0 additions & 55 deletions src/ids-host.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
IdsHost,
discoverServicesStub,
mungeDiagnosticEndpoint,
orderRecordsByPriorityWeight,
recordToUrl,
weightedRandom,
Expand Down Expand Up @@ -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(
Expand Down
21 changes: 0 additions & 21 deletions src/ids-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6cac4a7

Please sign in to comment.