diff --git a/openedx/core/djangoapps/user_api/accounts/utils.py b/openedx/core/djangoapps/user_api/accounts/utils.py index 1326c36a2eb5..e792c43a608e 100644 --- a/openedx/core/djangoapps/user_api/accounts/utils.py +++ b/openedx/core/djangoapps/user_api/accounts/utils.py @@ -85,11 +85,9 @@ def _get_username_from_social_link(platform_name, new_social_link): if not new_social_link: return new_social_link - # Parse the social link as if it were a URL. - parse_result = urlparse(new_social_link) - url_domain_and_path = parse_result[1] + parse_result[2] url_stub = re.escape(settings.SOCIAL_PLATFORMS[platform_name]['url_stub']) - username_match = re.search(r'(www\.)?' + url_stub + r'(?P.*?)[/]?$', url_domain_and_path, re.IGNORECASE) + username_match = re.search(r'(www\.)?' + url_stub + r'(?P.+)(\?.*)?$', new_social_link, re.IGNORECASE) + if username_match: username = username_match.group('username') else: