diff options
author | aib <aibok42@gmail.com> | 2019-01-02 15:24:00 +0300 |
---|---|---|
committer | aib <aibok42@gmail.com> | 2019-01-02 15:36:02 +0300 |
commit | 1771ec1822b33ef7c256dd5910b094576aee8da9 (patch) | |
tree | 5234dbc7497bd6902b05487003321eb6294465bd | |
parent | 9cd647a12f38de5082f4c052c2f355858b65f724 (diff) | |
download | routes-1771ec1822b33ef7c256dd5910b094576aee8da9.tar.gz |
Allow backslash to escape special characters \:*{} in route paths
-rw-r--r-- | routes/route.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/routes/route.py b/routes/route.py index 860a911..3b04f42 100644 --- a/routes/route.py +++ b/routes/route.py @@ -148,13 +148,22 @@ class Route(object): """Utility function to walk the route, and pull out the valid dynamic/wildcard keys.""" collecting = False + escaping = False current = '' done_on = '' var_type = '' just_started = False routelist = [] for char in routepath: - if char in [':', '*', '{'] and not collecting and not self.static \ + if escaping: + if char in ['\\', ':', '*', '{', '}']: + current += char + else: + current += '\\' + char + escaping = False + elif char == '\\': + escaping = True + elif char in [':', '*', '{'] and not collecting and not self.static \ or char in ['{'] and not collecting: just_started = True collecting = True |