This repository has been archived on 2024-09-11. You can view files and clone it, but cannot push or open issues or pull requests.
svrjs-blog-newsletter/cronjob/node_modules/@aws-sdk/util-endpoints/dist-es/lib/aws/isVirtualHostableS3Bucket.js
2024-05-26 22:54:55 +02:00

25 lines
681 B
JavaScript

import { isValidHostLabel } from "@smithy/util-endpoints";
import { isIpAddress } from "../isIpAddress";
export const isVirtualHostableS3Bucket = (value, allowSubDomains = false) => {
if (allowSubDomains) {
for (const label of value.split(".")) {
if (!isVirtualHostableS3Bucket(label)) {
return false;
}
}
return true;
}
if (!isValidHostLabel(value)) {
return false;
}
if (value.length < 3 || value.length > 63) {
return false;
}
if (value !== value.toLowerCase()) {
return false;
}
if (isIpAddress(value)) {
return false;
}
return true;
};