File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 11import re
22
3-
43def parse_cloudinary_url (cloudinary_url : str ) -> dict :
54 """Example: CLOUDINARY_URL=cloudinary://<api_key>:<api_secret>@<cloud_name>"""
65
7- pattern = re .compile (r"cloudinary://(\w+):(\w+)@(\w+)" )
6+ # Regex to handle characters like hyphens, underscores, and others
7+ pattern = re .compile (r'cloudinary://([^:]+):([^@]+)@([^/]+)' )
88 match = pattern .match (cloudinary_url )
99
10- return {"CLOUD_NAME" : match .group (3 ), "API_KEY" : match .group (1 ), "API_SECRET" : match .group (2 )}
10+ # Check if match is None to avoid AttributeError
11+ if not match :
12+ raise ValueError ("CLOUDINARY_URL format is incorrect" )
13+
14+ return {
15+ 'CLOUD_NAME' : match .group (3 ),
16+ 'API_KEY' : match .group (1 ),
17+ 'API_SECRET' : match .group (2 )
18+ }
You can’t perform that action at this time.
0 commit comments