Skip to content

Commit f788f23

Browse files
committed
Minor fix on checking if is a random request
1 parent cb75302 commit f788f23

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/routing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,18 @@ def __select_random_topic(prefix,topic_list):
124124

125125
if topic.endswith('/:random') or topic.lstrip('/') == ':random':
126126
#We strip the :random part and see if the query is valid by running a get_topics_list()
127+
if topic.lstrip('/') == ':random' : topic = topic.lstrip('/')
127128
prefix = topic[:-7]
128129
topic_list = [x[len(prefix):]
129130
for x in self.get_topics_list()
130131
if x.startswith(prefix)]
131132
if '' in topic_list: topic_list.remove('')
132133
if topic_list:
133-
# This is a correct formatted random query like /cpp/:random, the topic_list is not empty.
134+
# This is a correct formatted random query like /cpp/:random as the topic_list is not empty.
134135
random_topic = __select_random_topic(prefix,topic_list)
135136
return random_topic
136137
else:
137-
# This is a wrongly formatted random query like /xyxyxy/:random, the topic_list not empty
138+
# This is a wrongly formatted random query like /xyxyxy/:random as the topic_list is empty
138139
# we just strip the /:random and let the already implemented logic handle it.
139140
wrongly_formatted_random = topic[:-8]
140141
return wrongly_formatted_random

0 commit comments

Comments
 (0)