Skip to content

Commit

Permalink
Check for trailing slash before setting username
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Jun 20, 2024
1 parent 029fb0b commit 6c31153
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion wcivf/apps/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ def instagram_username(self):
@property
def linkedin_username(self):
linkedin_url = self.linkedin_url
return urlparse(linkedin_url).path.split("/")[-2]
# sometimes the url will have a trailing slash and othertimes it won't
# so we need to check for the trailing slash if it exists
if linkedin_url[-1] == "/":
return urlparse(linkedin_url).path.split("/")[-2]
return urlparse(linkedin_url).path.split("/")[-1]

@property
def youtube_username(self):
Expand Down
2 changes: 1 addition & 1 deletion wcivf/apps/people/tests/test_person_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_instagram_username(self):
assert self.person.instagram_username == "vickyfordmp"

def test_linkedin_username(self):
self.person.linkedin_url = "https://www.linkedin.com/in/vicky-ford/"
self.person.linkedin_url = "https://www.linkedin.com/in/vicky-ford"
assert self.person.linkedin_username == "vicky-ford"

def test_youtube_username(self):
Expand Down

0 comments on commit 6c31153

Please sign in to comment.