Skip to content

Commit a74756b

Browse files
Enhance dynamic routing by replacing spaces with underscores in route paths\
1 parent 478e801 commit a74756b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/workflows_cdk/core/dynamic_routing.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ def find_schema_files(directory: str) -> Dict[str, Dict[str, Any]]:
8585
if schema_data:
8686
# Calculate the route path based on directory structure
8787
rel_path = os.path.relpath(root, directory)
88-
route_path = '/' + rel_path.replace(os.sep, '/')
88+
# Replace spaces with underscores in path parts
89+
path_parts = rel_path.split(os.sep)
90+
path_parts = [part.replace(" ", "_") for part in path_parts]
91+
route_path = '/' + '/'.join(path_parts)
8992
if route_path == '/.': # Handle root directory case
9093
route_path = ''
9194
schema_files[route_path] = schema_data
@@ -298,6 +301,8 @@ def _create_route_info(self, function: Callable, rule: Optional[str] = None, opt
298301
relative_path = module_file_path.relative_to(routes_directory)
299302
# Generate base path from routes directory structure
300303
path_parts = list(relative_path.parent.parts)
304+
# Replace spaces with underscores in each path part
305+
path_parts = [part.replace(" ", "_") for part in path_parts]
301306
base_path = "/" + "/".join(path_parts)
302307

303308
# --- Module Metadata Generation ---

0 commit comments

Comments
 (0)