Skip to content

Commit

Permalink
Fixed manky slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Collins committed Apr 16, 2020
1 parent b6bfad0 commit 2ca5c51
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions labthings/server/labthing.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def _create_base_routes(self):
self.add_view(TaskView, "/tasks/<task_id>", endpoint=TASK_ENDPOINT)

def _create_base_sockets(self):
self.sockets.add_url_rule(f"{self.url_prefix}", self._socket_handler)
self.sockets.add_url_rule(self._complete_url("", ""), self._socket_handler)

def _socket_handler(self, ws):
# Create a socket subscriber
Expand Down Expand Up @@ -232,7 +232,12 @@ def _complete_url(self, url_part, registration_prefix):
blueprint. Generally speaking, BlueprintSetupState.url_prefix
"""
parts = [registration_prefix, self.url_prefix, url_part]
return "".join([part for part in parts if part])
u = "".join([part for part in parts if part])
if u == "":
u = "/"
if u[0] != "/":
u = f"/{u}"
return u

def add_view(self, resource, *urls, endpoint=None, **kwargs):
"""Adds a view to the api.
Expand Down

0 comments on commit 2ca5c51

Please sign in to comment.