Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions gradio/cli/commands/deploy_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

import gradio as gr

_invalid_chars_pattern = re.compile(r"[^a-zA-Z0-9\-._]")

_hyphens_pattern = re.compile(r"-+")

repo_directory = os.getcwd()
readme_file = os.path.join(repo_directory, "README.md")
github_action_template = os.path.join(
Expand Down Expand Up @@ -112,10 +116,9 @@ def add_configuration_to_readme(

def format_title(title: str):
title = title.replace(" ", "_")
title = re.sub(r"[^a-zA-Z0-9\-._]", "", title)
title = re.sub("-+", "-", title)
while title.startswith("."):
title = title[1:]
title = _invalid_chars_pattern.sub("", title)
title = _hyphens_pattern.sub("-", title)
title = title.lstrip(".")
return title


Expand Down