bot / node_modules /@aws-sdk /config-resolver /dist-cjs /endpointsConfig /utils /getEndpointFromRegion.js
Download node_modules/@aws-sdk/config-resolver/dist-cjs/endpointsConfig/utils/getEndpointFromRegion.js from sweet2004/bot: direct link, hf CLI and curl.
- Browser
- Download file 963 Bytes
-
https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/config-resolver/dist-cjs/endpointsConfig/utils/getEndpointFromRegion.js
- Command line
-
hf download hf://spaces/sweet2004/bot/node_modules/@aws-sdk/config-resolver/dist-cjs/endpointsConfig/utils/getEndpointFromRegion.js
-
curl -L -o getEndpointFromRegion.js https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/config-resolver/dist-cjs/endpointsConfig/utils/getEndpointFromRegion.js
963 Bytes
| ; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.getEndpointFromRegion = void 0; | |
| const getEndpointFromRegion = async (input) => { | |
| var _a; | |
| const { tls = true } = input; | |
| const region = await input.region(); | |
| const dnsHostRegex = new RegExp(/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])$/); | |
| if (!dnsHostRegex.test(region)) { | |
| throw new Error("Invalid region in client config"); | |
| } | |
| const useDualstackEndpoint = await input.useDualstackEndpoint(); | |
| const useFipsEndpoint = await input.useFipsEndpoint(); | |
| const { hostname } = (_a = (await input.regionInfoProvider(region, { useDualstackEndpoint, useFipsEndpoint }))) !== null && _a !== void 0 ? _a : {}; | |
| if (!hostname) { | |
| throw new Error("Cannot resolve hostname from client config"); | |
| } | |
| return input.urlParser(`${tls ? "https:" : "http:"}//${hostname}`); | |
| }; | |
| exports.getEndpointFromRegion = getEndpointFromRegion; | |