summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraib <aibok42@gmail.com>2019-01-02 15:24:00 +0300
committeraib <aibok42@gmail.com>2019-01-02 15:36:02 +0300
commit1771ec1822b33ef7c256dd5910b094576aee8da9 (patch)
tree5234dbc7497bd6902b05487003321eb6294465bd
parent9cd647a12f38de5082f4c052c2f355858b65f724 (diff)
downloadroutes-1771ec1822b33ef7c256dd5910b094576aee8da9.tar.gz
Allow backslash to escape special characters \:*{} in route paths
-rw-r--r--routes/route.py11
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