Skip to content

Commit cf31a03

Browse files
committed
Catch edge cases were delimiters are wrongfully caught
1 parent 2463185 commit cf31a03

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lib/cheat_wrapper.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,25 @@ def _add_section_name(query):
2626
if '/' in query:
2727
return query
2828
if ' ' in query:
29-
# for standalone queries only that may contain ' '
30-
return "%s/%s" % tuple(query.split(' ', 1))
31-
return "%s/%s" % tuple(query.split('+', 1))
29+
delim = " "
30+
elif '+' in query:
31+
delim = "+"
32+
33+
index = 0
34+
length = len(query)
35+
while index != length:
36+
37+
index = query.index(delim, index) + 1
38+
39+
try:
40+
comparison = query.index(delim, index)
41+
except ValueError:
42+
comparison = -1
43+
44+
if (index != comparison and index != length):
45+
return "%s/%s" % (query[:index-1], query[index:])
46+
47+
return query
3248

3349
def cheat_wrapper(query, request_options=None, output_format='ansi'):
3450
"""

0 commit comments

Comments
 (0)