Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions beautifier/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import os
from urllib.parse import urlsplit, urlunsplit

__version__ = "0.5.5"

Expand Down Expand Up @@ -54,14 +55,19 @@ def username(self):
else:
return {'msg': 'feature is currently available only with linkedin urls'}


@property
def scheme(self):
return urlsplit(self.cleanup).scheme

@property
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dilan1020 can you please remove the extra whitespace here as well?

def path(self):
return urlsplit(self.cleanup).path


@property
def domain(self):
"""
Return domain from the url
"""
remove_pac = self.cleanup.replace(
"https://", "").replace("http://", "").replace("www.", "")
try:
return remove_pac.split('/')[0]
except:
return None
return urlsplit(self.cleanup).netloc
11 changes: 11 additions & 0 deletions beautifier/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ def test_url_domain(self):
'''
self.assertEqual(self.url.domain, 'in.linkedin.com')

def test_url_scheme(self):
'''
Checks the url scheme is returned
'''
self.assertEqual(self.url.scheme, 'https')

def test_url_path(self):
'''
Checks the url path is returned
'''
self.assertEqual(self.url.path, '/in/sachinphilip')

if __name__ == '__main__':
unittest.main()