SushantGautam commited on
Commit
bd52915
·
1 Parent(s): 03fbd26

Improve URL parsing in parse_id_from_url function to handle invalid URLs gracefully

Browse files
Files changed (1) hide show
  1. populate_user.py +3 -5
populate_user.py CHANGED
@@ -10,11 +10,9 @@ from urllib.parse import urlparse
10
 
11
 
12
  def parse_id_from_url(url):
13
- try:
14
- return urlparse(url).path.strip('/').split('/')[-1]
15
- except Exception as e:
16
- print(f"Error parsing URL {url}: {e}")
17
- breakpoint()
18
 
19
 
20
  def add_author(user_info, updated_date):
 
10
 
11
 
12
  def parse_id_from_url(url):
13
+ if (not url) or (not url.startswith("http")):
14
+ return "N/A"
15
+ return urlparse(url).path.strip('/').split('/')[-1]
 
 
16
 
17
 
18
  def add_author(user_info, updated_date):