Skip to content
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

Special rule for vercel.app #408

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
69 changes: 51 additions & 18 deletions PyFunceble/checker/availability/extras/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def __init__(self, status: Optional[AvailabilityCheckerStatus] = None) -> None:
r"\.sz.id$": [(self.switch_to_down_if_status_code, 302)],
r"\.translate\.goog$": [(self.switch_to_down_if_status_code, 403)],
r"\.tumblr\.com$": [(self.switch_to_down_if_status_code, 404)],
r"\.vercel\.app$": [
(self.switch_to_down_if_status_code, "451"),
self.handle_vercel_dot_app
],
r"\.web\.app$": [(self.switch_to_down_if_status_code, 404)],
r"\.wix\.com$": [(self.switch_to_down_if_status_code, 404)],
r"^s3\.ap-south-1\.amazonaws\.com$": [
Expand Down Expand Up @@ -170,24 +174,6 @@ def handle_blogspot(self) -> "ExtraRulesHandler":

return self

def handle_wordpress_dot_com(self) -> "ExtraRulesHandler":
"""
Handles the :code:`wordpress.com` case.

.. warning::
This method assume that we know that we are handling a blogspot domain.
"""

regex_wordpress = [r"doesn’t exist", r"no\slonger\savailable"]

self.do_on_body_match(
self.req_url,
regex_wordpress,
method=self.switch_to_down,
allow_redirects=True,
)

return self

def handle_fc2_dot_com(self) -> "ExtraRulesHandler":
"""
Expand Down Expand Up @@ -227,6 +213,53 @@ def handle_imgur_dot_com(self) -> "ExtraRulesHandler":

return self

def handle_vercel_dot_app(self) -> "ExtraRulesHandler":
"""
Handles the :code:`vercel.app` case.

.. warning::
This method assume that we know that we are handling a vercel.app domain.
"""

regex_vercel = [r"This%20Deployment%20has%20been%20disabled"]

self.do_on_header_match(
self.req_url,
{"x-vercel-error": ["DEPLOYMENT_DISABLED"]},
method=self.switch_to_down,
match_mode="std",
strict=True,
allow_redirects=False,
)

self.do_on_body_match(
self.req_url,
regex_vercel,
method=self.switch_to_down,
allow_redirects=False,
)

return self

def handle_wordpress_dot_com(self) -> "ExtraRulesHandler":
"""
Handles the :code:`wordpress.com` case.

.. warning::
This method assume that we know that we are handling a blogspot domain.
"""

regex_wordpress = [r"doesn’t exist", r"no\slonger\savailable"]

self.do_on_body_match(
self.req_url,
regex_wordpress,
method=self.switch_to_down,
allow_redirects=True,
)

return self

def __handle_active2inactive(self) -> "ExtraRulesHandler":
"""
Handles the status deescalation.
Expand Down