From f788f238a464fc6ef50f3943922a770a35965e02 Mon Sep 17 00:00:00 2001 From: fedeb Date: Sat, 7 Nov 2020 20:48:38 +0100 Subject: [PATCH] Minor fix on checking if is a random request --- lib/routing.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/routing.py b/lib/routing.py index 0c220b2..d8ac53c 100644 --- a/lib/routing.py +++ b/lib/routing.py @@ -124,17 +124,18 @@ class Router(object): if topic.endswith('/:random') or topic.lstrip('/') == ':random': #We strip the :random part and see if the query is valid by running a get_topics_list() + if topic.lstrip('/') == ':random' : topic = topic.lstrip('/') prefix = topic[:-7] topic_list = [x[len(prefix):] for x in self.get_topics_list() if x.startswith(prefix)] if '' in topic_list: topic_list.remove('') if topic_list: - # This is a correct formatted random query like /cpp/:random, the topic_list is not empty. + # This is a correct formatted random query like /cpp/:random as the topic_list is not empty. random_topic = __select_random_topic(prefix,topic_list) return random_topic else: - # This is a wrongly formatted random query like /xyxyxy/:random, the topic_list not empty + # This is a wrongly formatted random query like /xyxyxy/:random as the topic_list is empty # we just strip the /:random and let the already implemented logic handle it. wrongly_formatted_random = topic[:-8] return wrongly_formatted_random