Skip to content

Commit 9f347b1

Browse files
committed
Use /v3/index.json for NuGet feed check
1 parent 6153577 commit 9f347b1

2 files changed

Lines changed: 38 additions & 10 deletions

File tree

lib/start-proxy-action.js

Lines changed: 14 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy/reachability.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ import { getErrorMessage } from "../util";
77

88
import { getAddressString, ProxyInfo, Registry } from "./types";
99

10+
/** Represents registry-specific connection test configurations. */
11+
export interface ConnectionTestConfig {
12+
/** An optional path to append to the end of the base url. */
13+
path?: string;
14+
}
15+
16+
/** A partial mapping of registry types to extra connection test configurations. */
17+
const connectionTestConfig: Partial<Record<string, ConnectionTestConfig>> = {
18+
nuget_feed: { path: "/v3/index.json" },
19+
};
20+
1021
export class ReachabilityError extends Error {
1122
constructor(public readonly statusCode?: number | undefined) {
1223
super();
@@ -92,6 +103,7 @@ export async function checkConnections(
92103
}
93104

94105
for (const registry of proxy.registries) {
106+
const config = connectionTestConfig[registry.type];
95107
const address = getAddressString(registry);
96108
const url = URL.parse(address);
97109

@@ -102,18 +114,25 @@ export async function checkConnections(
102114
continue;
103115
}
104116

117+
const testUrl =
118+
config?.path === undefined ? url : new URL(config.path, url);
119+
105120
try {
106-
logger.debug(`Testing connection to ${url}...`);
107-
const statusCode = await backend.checkConnection(url);
121+
logger.debug(`Testing connection to ${testUrl}...`);
122+
const statusCode = await backend.checkConnection(testUrl);
108123

109-
logger.info(`Successfully tested connection to ${url} (${statusCode})`);
124+
logger.info(
125+
`Successfully tested connection to ${testUrl} (${statusCode})`,
126+
);
110127
result.add(registry);
111128
} catch (e) {
112129
if (e instanceof ReachabilityError && e.statusCode !== undefined) {
113-
logger.info(`Connection test to ${url} failed. (${e.statusCode})`);
130+
logger.info(
131+
`Connection test to ${testUrl} failed. (${e.statusCode})`,
132+
);
114133
} else {
115134
logger.warning(
116-
`Connection test to ${url} failed: ${getErrorMessage(e)}`,
135+
`Connection test to ${testUrl} failed: ${getErrorMessage(e)}`,
117136
);
118137
}
119138
}

0 commit comments

Comments
 (0)