bool AlibabaCloud::OSS::IsValidBucketName()

in sdk/src/utils/Utils.cc [631:648]


bool AlibabaCloud::OSS::IsValidBucketName(const std::string &bucketName)
{
#if defined(__GNUG__) && __GNUC__ < 5
    if (bucketName.size() < 3 || bucketName.size() > 63)
        return false;
    for (auto it = bucketName.begin(); it != bucketName.end(); it++) {
        if (!((*it >= 'a' && *it <= 'z') || (*it >= '0' && *it <= '9') || *it == '-'))
            return false;
    }
    if (*bucketName.begin() == '-' || *bucketName.rbegin() == '-')
        return false;
    return true;
#else
    if (bucketName.empty())
        return false;
    return std::regex_match(bucketName, bucketNamePattern);
#endif
}