From 9acf2c8a9268a994220b07b3aa018a68dffedff0 Mon Sep 17 00:00:00 2001 From: izzy lyseggen Date: Wed, 17 Nov 2021 15:59:51 +0000 Subject: [PATCH] fix(wrapper): fix for nested branches --- specklepy/api/credentials.py | 4 ++-- tests/test_wrapper.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/specklepy/api/credentials.py b/specklepy/api/credentials.py index 3bdc188..6da65c4 100644 --- a/specklepy/api/credentials.py +++ b/specklepy/api/credentials.py @@ -144,9 +144,9 @@ class StreamWrapper: parsed = urlparse(url) self.host = parsed.netloc self.use_ssl = parsed.scheme == "https" - segments = parsed.path.strip("/").split("/") + segments = parsed.path.strip("/").split("/", 3) - if not segments or len(segments) > 4 or len(segments) < 2: + if not segments or len(segments) < 2: raise SpeckleException( f"Cannot parse {url} into a stream wrapper class - invalid URL provided." ) diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index c447846..54818b6 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py @@ -18,6 +18,14 @@ class TestWrapper: assert wacky_wrap.branch_name == "🍕⬅🌟 you wat?" assert wrap.type == "branch" + def test_parse_nested_branch(self): + wrap = StreamWrapper( + "https://testing.speckle.dev/streams/4c3ce1459c/branches/izzy/dev" + ) + + assert wrap.branch_name == "izzy/dev" + assert wrap.type == "branch" + def test_parse_commit(self): wrap = StreamWrapper( "https://testing.speckle.dev/streams/4c3ce1459c/commits/8b9b831792"