Skip to content

Conversation

daH005
Copy link
Contributor

@daH005 daH005 commented Jan 11, 2025

Hello. In my project I tried to pass a regular expression to origins, but it didn't work.
I think this will not be superfluous for the project.
Idea taken from https://github.com/corydolphin/flask-cors/blob/main/flask_cors/core.py

@daH005 daH005 changed the title Add regex support in websockets.asyncio.server.serve(origins=...) Add regex support in ServerProtocol(origins=...) Jan 12, 2025
@aaugustin
Copy link
Member

Yes, that's a valid improvement.

I don't like the heuristics to tell what's likely a regex. Instead, how about we keep strict backwards-compatibility when the argument is a str and add support for re.Pattern?

@daH005
Copy link
Contributor Author

daH005 commented Jan 12, 2025

I agree with you. I did this and I also added tests.

@daH005 daH005 force-pushed the main branch 2 times, most recently from 5fffd54 to 13ac1e7 Compare January 13, 2025 07:15
@aaugustin
Copy link
Member

I don't always find time to work on websockets outside of weekends — but I'll get to your MR eventually. Thank you.

@aaugustin
Copy link
Member

If you want to run the same checks as CI locally, you can simply run tox (and ignore Python version that aren't installed — this MR won't break on specific Python versions). Or you can use make style (fixes automatically formatting, imports, etc.) +make coverage (runs unittest) + make types (checks types).

@aaugustin aaugustin merged commit 7e617b2 into python-websockets:main Jan 19, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants