davanstrien HF staff commited on
Commit
185bd85
1 Parent(s): b89f914
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -52,15 +52,12 @@ def navigate_dataset(dataset_ids, index, direction):
52
 
53
 
54
  def get_display_name(collection_id):
55
- # Split the collection_id into parts
56
- parts = collection_id.split("/")
57
- if len(parts) == 2:
58
- owner, name = parts
59
- # Remove the ID part (assumed to be 32 characters of hexadecimal after the last hyphen)
60
- name = re.sub(r"-[a-f0-9]{32}$", "", name)
61
- return f"{owner}/{name}"
62
  else:
63
- # If the format is unexpected, return the original
64
  return collection_id
65
 
66
 
 
52
 
53
 
54
  def get_display_name(collection_id):
55
+ # Pattern to match username/repo-name with an optional ID of 16 or more hexadecimal characters
56
+ pattern = r"^(.+?)-([a-f0-9]{16,})$"
57
+ if match := re.match(pattern, collection_id):
58
+ return match[1]
 
 
 
59
  else:
60
+ # If no match, return the original
61
  return collection_id
62
 
63