8000 `url`: Improvements to parsing URLs by tony · Pull Request #423 · vcs-python/libvcs · GitHub
[go: up one dir, main page]

Skip to content

url: Improvements to parsing URLs #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat(url): Add is_explicit for is_valid on Svn and Mercurial
  • Loading branch information
tony committed Sep 25, 2022
commit d4a03b965e395799273de0c39c09c9bd4c4cfe97
6 changes: 6 additions & 0 deletions src/libvcs/url/hg.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
>>> HgBaseURL.is_valid(url='notaurl')
False
"""
if is_explicit is not None:
return any(
re.search(rule.pattern, url)
for rule in cls.rule_map.values()
if rule.is_explicit == is_explicit
)
return any(re.search(rule.pattern, url) for rule in cls.rule_map.values())

def to_url(self) -> str:
Expand Down
6 changes: 6 additions & 0 deletions src/libvcs/url/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
>>> SvnURL.is_valid(url='notaurl')
False
"""
if is_explicit is not None:
return any(
re.search(rule.pattern, url)
for rule in cls.rule_map.values()
if rule.is_explicit == is_explicit
)
return any(re.search(rule.pattern, url) for rule in cls.rule_map.values())

def to_url(self) -> str:
Expand Down
0