chg: [expansion:extract_url_components] Better support in case attributes are not defined

pull/630/head
Sami Mokaddem 2023-07-13 10:14:04 -04:00
parent b01dc1d22b
commit fb86bb0510
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 6 additions and 3 deletions

View File

@ -22,9 +22,12 @@ def createObjectFromURL(url):
if parsed['subdomain'] is not None:
obj.add_attribute('subdomain', type='text', value=parsed['subdomain'])
obj.add_attribute('scheme', type='text', value=parsed['scheme'])
obj.add_attribute('resource_path', type='text', value=parsed['resource_path'])
obj.add_attribute('query_string', type='text', value=parsed['query_string'])
obj.add_attribute('port', type='port', value=parsed['port'])
if parsed['resource_path'] is not None:
obj.add_attribute('resource_path', type='text', value=parsed['resource_path'])
if parsed['query_string'] is not None:
obj.add_attribute('query_string', type='text', value=parsed['query_string'])
if parsed['port'] is not None:
obj.add_attribute('port', type='port', value=parsed['port'])
obj.add_attribute('host', type='hostname', value=parsed['host'])
if parsed['fragment'] is not None:
obj.add_attribute('fragment', type='text', value=parsed['fragment'])