Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion packages/opencloning/src/opencloning/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def parse_bool(value: str | bool) -> bool:
ALLOWED_ORIGINS = ['http://localhost:3000', 'http://localhost:5173', 'http://localhost:3002']
if os.environ.get('ALLOWED_ORIGINS') is not None:
# Remove trailing slash from each origin if ends with one
ALLOWED_ORIGINS = [origin.rstrip('/') for origin in os.environ['ALLOWED_ORIGINS'].split(',')]
ALLOWED_ORIGINS = [
origin.rstrip('/') for origin in os.environ['ALLOWED_ORIGINS'].split(',') if origin.rstrip('/') != ''
]


# External services settings =================================
Expand Down
10 changes: 10 additions & 0 deletions packages/opencloning/tests/test_app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,13 @@ def test_frontend_config_from_env(self):
self.assertEqual(app_settings.frontend_config.enableAssembler, False)
self.assertEqual(app_settings.frontend_config.enablePlannotate, False)
self.assertEqual(app_settings.frontend_config.staticContentPath, '/tmp/static')

def test_allowed_origins_empty_string(self):
self.monkeypatch2.setenv('ALLOWED_ORIGINS', 'hello,,bye')
reload(app_settings)
self.assertEqual(app_settings.settings.ALLOWED_ORIGINS, ['hello', 'bye'])
self.monkeypatch2.setenv('ALLOWED_ORIGINS', '')
reload(app_settings)
self.assertEqual(app_settings.settings.ALLOWED_ORIGINS, [])
self.monkeypatch2.undo()
reload(app_settings)
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading