@@ -198,8 +198,8 @@ def format_region(region):
198
198
if not region :
199
199
raise CosClientError ("region is required not empty!" )
200
200
region = to_unicode (region )
201
- if not re .match ('^[A-Za-z0-9][A-Za-z0-9\-]+ [A-Za-z0-9]$' , region ):
202
- raise CosClientError ("region:%s format is illegal, only digit, letter and - is allowed!" % region )
201
+ if not re .match ('^[A-Za-z0-9][A-Za-z0-9. \-]* [A-Za-z0-9]$' , region ):
202
+ raise CosClientError ("region format is illegal, only digit, letter and - is allowed!" )
203
203
if region .find (u'cos.' ) != - 1 :
204
204
return region # 传入cos.ap-beijing-1这样显示加上cos.的region
205
205
if region == u'cn-north' or region == u'cn-south' or region == u'cn-east' or region == u'cn-south-2' or region == u'cn-southwest' or region == u'sg' :
@@ -233,8 +233,8 @@ def format_bucket(bucket, appid):
233
233
raise CosClientError ("bucket is not string" )
234
234
if not bucket :
235
235
raise CosClientError ("bucket is required not empty" )
236
- if not re .match ('^[A-Za-z0-9][A-Za-z0-9\-]+ [A-Za-z0-9]$' , bucket ):
237
- raise CosClientError ("bucket:%s format is illegal, only digit, letter and - is allowed!" % bucket )
236
+ if not ( re .match ('^[A-Za-z0-9][A-Za-z0-9\-]* [A-Za-z0-9]$' , bucket ) or re . match ( '^[A-Za-z0-9]$' , bucket ) ):
237
+ raise CosClientError ("bucket format is illegal, only digit, letter and - is allowed!" )
238
238
# appid为空直接返回bucket
239
239
if not appid :
240
240
return to_unicode (bucket )
0 commit comments