Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes the route resolver pattern compatible with MicroPython's re #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gattag
Copy link

@Gattag Gattag commented Apr 10, 2021

MicroPython does not support named classes within [...] (i.e. no [\\w] or [\\s] )

Fixes #38

@2e0byo
Copy link

2e0byo commented Sep 12, 2021

Was just going to PR for the same problem...

However I don't understand [\w.]. Since . matches anything, what's is \w doing? Doubtless something as I've no great experience with re.

@Gattag
Copy link
Author

Gattag commented Sep 13, 2021

However I don't understand [\w.]. Since . matches anything, what's is \w doing? Doubtless something as I've no great experience with re.

When . is inside a character class [...], it not longer matches anything and only matches the literal . character

@tf131
Copy link

tf131 commented Sep 22, 2021

works fine, thank you

@2e0byo
Copy link

2e0byo commented Sep 22, 2021

However I don't understand [\w.]. Since . matches anything, what's is \w doing? Doubtless something as I've no great experience with re.

When . is inside a character class [...], it not longer matches anything and only matches the literal . character

Duh! Thank you. I was being daft.

@@ -54,7 +54,7 @@ def RegisterRoute(handler, method, routePath, name=None) :
if not argName :
raise Exception
argNames.append(argName)
regex += '/([\\w.]*)'
regex += '/([A-Za-z0-9_.]*)'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A suggestion here. Can we add support for whitespace as well? In order to support links like
http://example.com/some page that would be translated from web browsers with a %20
I have tested in CPython to add \s and works but if micropython can't support \w I am not sure how to handle it

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.

Route Arguments Not Working
4 participants