1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 13:16:44 +02:00

Catch edge cases were delimiters are wrongfully caught

This commit is contained in:
Jan200101
2021-10-24 21:14:27 +02:00
parent 2463185329
commit cf31a03c32
+19 -3
View File
@@ -26,9 +26,25 @@ def _add_section_name(query):
if '/' in query:
return query
if ' ' in query:
# for standalone queries only that may contain ' '
return "%s/%s" % tuple(query.split(' ', 1))
return "%s/%s" % tuple(query.split('+', 1))
delim = " "
elif '+' in query:
delim = "+"
index = 0
length = len(query)
while index != length:
index = query.index(delim, index) + 1
try:
comparison = query.index(delim, index)
except ValueError:
comparison = -1
if (index != comparison and index != length):
return "%s/%s" % (query[:index-1], query[index:])
return query
def cheat_wrapper(query, request_options=None, output_format='ansi'):
"""