diff --git a/wcivf/apps/people/models.py b/wcivf/apps/people/models.py index 7c3a840b5..f3e974a2d 100644 --- a/wcivf/apps/people/models.py +++ b/wcivf/apps/people/models.py @@ -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): diff --git a/wcivf/apps/people/tests/test_person_models.py b/wcivf/apps/people/tests/test_person_models.py index 1c5db89de..c537b01d2 100644 --- a/wcivf/apps/people/tests/test_person_models.py +++ b/wcivf/apps/people/tests/test_person_models.py @@ -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):