1414from sanic_cors import CORS
1515from websockets .legacy .protocol import WebSocketCommonProtocol
1616
17- from idom .config import IDOM_WEB_MODULES_DIR
1817from idom .core .hooks import Context , create_context , use_context
1918from idom .core .layout import Layout , LayoutEvent
2019from idom .core .serve import (
2726from idom .core .types import RootComponentConstructor
2827
2928from ._asgi import serve_development_asgi
30- from .utils import CLIENT_BUILD_DIR , client_build_dir_path
29+ from .utils import safe_client_build_dir_path , safe_web_modules_dir_path
3130
3231
3332logger = logging .getLogger (__name__ )
@@ -122,7 +121,7 @@ async def single_page_app_files(
122121 path : str = "" ,
123122 ) -> response .HTTPResponse :
124123 path = urllib_parse .unquote (path )
125- return await response .file (CLIENT_BUILD_DIR / client_build_dir_path (path ))
124+ return await response .file (safe_client_build_dir_path (path ))
126125
127126 blueprint .add_route (single_page_app_files , "/" )
128127 blueprint .add_route (single_page_app_files , "/<path:path>" )
@@ -132,9 +131,8 @@ async def web_module_files(
132131 path : str ,
133132 _ : str = "" , # this is not used
134133 ) -> response .HTTPResponse :
135- wm_dir = IDOM_WEB_MODULES_DIR .current
136134 path = urllib_parse .unquote (path )
137- return await response .file (wm_dir . joinpath ( * path . split ( "/" ) ))
135+ return await response .file (safe_web_modules_dir_path ( path ))
138136
139137 blueprint .add_route (web_module_files , "/_api/modules/<path:path>" )
140138 blueprint .add_route (web_module_files , "/<_:path>/_api/modules/<path:path>" )
0 commit comments