Skip to content

Commit

Permalink
fix: global extract function should allow `include_psl_private_domain…
Browse files Browse the repository at this point in the history
…s`arg
  • Loading branch information
brycedrennan authored and john-kurkowski committed Oct 22, 2020
1 parent be5fb11 commit 882a94d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions tests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import tldextract
from tldextract.cache import DiskCache
from tldextract.suffix_list import SuffixListNotFound
from tldextract.tldextract import ExtractResult
from .helpers import temporary_dir


Expand Down Expand Up @@ -262,3 +263,9 @@ def test_tlds_property():
include_psl_private_domains=False
)
assert len(extract_private.tlds) > len(extract_public.tlds)


def test_global_extract():
assert tldextract.extract("foo.blogspot.com") == ExtractResult(subdomain='foo', domain='blogspot', suffix='com')
assert tldextract.extract("foo.blogspot.com", include_psl_private_domains=True) == \
ExtractResult(subdomain='', domain='foo', suffix='blogspot.com')
4 changes: 2 additions & 2 deletions tldextract/tldextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ def _get_tld_extractor(self):


@wraps(TLD_EXTRACTOR.__call__)
def extract(url):
return TLD_EXTRACTOR(url)
def extract(url, include_psl_private_domains=False):
return TLD_EXTRACTOR(url, include_psl_private_domains=include_psl_private_domains)


@wraps(TLD_EXTRACTOR.update)
Expand Down

0 comments on commit 882a94d

Please sign in to comment.